Home >> Linux >> Write LaTeX documents with LyX

Write LaTeX documents with LyX

Follow @LinuxUserMag

LaTeX is a typesetting system that gives you full control over how everything in your document is rendered. The problem is its really steep learning curve. One option is to use a basic text editor and learn all the markup you need for your document. The other option is to use an application that wraps the markup to some degree. LyX does this very nicely. While a fully WYSIWYG editor for LaTeX doesn’t make sense (since your doc isn’t fully rendered until sent to an output device), LyX does provide a pseudo-WYSIWYG interface where you can see how different regions will be rendered.

In this tutorial, you’ll learn how to create a new document and create various content sections, like images, tables and lists. You will also learn how to use various document settings, like the document class, to control the overall options used during document rendering. Since LaTeX is a typesetting system, LyX will let you output to several formats, like PDF, Postscript, HTML, plain text and OpenDocument files. Regardless of whether you are writing a book, a journal article or a set of presentation slides, LyX will help you get your work done with minimal fuss.

You can view what yout document will look like by rendering it to a PDF file
You can view what yout document will look like by rendering it to a PDF file




Step by Step

Step 01


The first step is to get LyX installed on your system. Most distributions should have a package available. For your non-Linux friends, there are binaries available for Windows, Mac OS X, and even OS/2 and Haiku. As always, you can download the source code and build from scratch in the worst-case scenario.

Step 02

Opening a new document

When you first start up LyX, the main window opens up with a splash screen image displayed. You actually have to tell LyX that you want to start a new document before you can start writing. You can start a new document by clicking the menu item File>New.

Step 03

Setting the document class

Many of the layout properties for your document are set to defaults based on the class of your document. You can set this by clicking the menu item Document>Settings. This will pop up a dialog window that we’ll use for the next few steps. The drop-down list will give you a very full list of possible document classes.

Step 04

Text layout

While the document class sets the defaults for your document, you still have full control to change anything in the document. The Text Layout option lets you change the indentation size to a custom increment. The vertical spacing and line spacing can also be customised. You also have the option to make your document two-column here.

Step 05

Page layout

LaTeX figures out the actual rendering of your document based on a page layout. You can select one of a number of standard page formats, or set a custom page size. You can set whether the page is oriented as either portrait or landscape mode.

Step 06

Numbering and the TOC

Documents are broken down into several nested subregions. How these regions are handled in the layout is decided by the document class. You can also set whether these regions are numbered or not, and whether they show up in the generated table of contents.

Step 07

View source

Now that your document is set up, you can start typing. LyX gives you a pseudo- WYSISYG display of the text. But LaTeX is a purely text-based markup language, so you can always see the actual source code to verify what LyX is putting into your document. To see the source, just click on the menu item View>View Source.

Step 08


The first item your document will need is a title. In LaTeX, you need to worry about what a particular piece of text is supposed to be, not what it will look like. So at this stage, you can type in your title text. To identify it as a title, you can click the drop-down at the top right of the toolbar and select Title.

Step 09


Hitting Enter will give you a new line, with the type back to Standard. You can here enter your name and set the type to Author, again with the drop-down at the top right of the toolbar. Where and how this will get rendered depends on the document class and the output format.

Step 10


You should have noticed that there is a date option in the drop-down. You don’t need to use this if you don’t wish to. LyX will automatically add the current date when you actually render the document into an output format.

Step 11


If you are writing an article, or a report, you may need to include an abstract of the subject matter being covered. If you have already written your abstract, you can highlight the region with your mouse and select Abstract from the drop- down. This adds the title ‘Abstract’ and changes the format of the text.

Step 12


In most documents, you will probably want to break the text down into sections, and possibly subsections. Sections are defined
by giving them a title. For instance, if your first section is going to be an introduction, then you would type the section title as ‘Introduction’ and set the type in the drop-down to Section. The actual text for this section would be set to the type Standard.

Write LaTeX documents with LyX

Step 13

Mathematical formulae

Mathematical formulae are always a problem area in document typesetting. Many people in the sciences first move to LaTeX because of the ability to fully control equations by explicitly laying out all of the elements. However, for more complex equations, this can still be confusing. Therefore LyX provides an equation writer tools that helps you create the LaTeX required to lay out your formula in your document. You can set the type of maths to be either inline with your text, or to be centred and displayed on its own.

Step 14


There are several different types of lists available for your use. Both numbered and unnumbered lists are available as buttons on the main toolbar. To start a list, click on one of the buttons and start typing the first item. Hitting the Enter key will give you a new item to enter. Hitting Enter on an empty item will drop you out of the list section.

Step 15


You can add a table by clicking on the menu item Insert>Table. A dialog will appear where you can set the number of rows and columns. The first row is set aside as a header for the columns, but you can change this in the LaTeX source.

Step 16


Clicking on the menu item Insert>Graphics opens a dialog window where you can select an image file to insert into your document. You can either set a scaling factor, or an explicit width and height for its display. You can also rotate your image through X degrees. You also have the option to control if and how the image gets clipped to a bounding box.

Step 17


Now that you have a bunch of content in your document, you probably want to get an idea of what it will look like once it is fully rendered. You can get LyX to generate a PDF for viewing by clicking the menu item View>View [PDF
(pdflatex)]. There are also other viewing options, in case you want to render your document using other methods.

Step 18


Most people need help when it comes to making sure everything is spelled correctly. If you want to use the system default spellchecking engine, you can simply click on the menu item Tools>Spellchecker. You can change the engine being used by selecting it in the options window.

Step 19


Linux users have had problems, traditionally, when dealing with fonts. This extends to applications like LaTeX. LyX includes options that help you correctly set up TrueType fonts, allowing you to use fonts other than those
provided by your LaTeX installation. This is defined in the Document Settings dialog, where you can set the family, encoding and fonts to use for Roman, Sans Serif and Typewriter.

Step 20

Output formats

Now that you have your document finished, you will want to render it to some final output format. A common choice is either PostScript or PDF. This way, you know that it will look the same, regardless of who you give it to. But you have several other options available, too. You can output to HTML, rich text, plain text or even OpenDocument.

Follow @LinuxUserMag

Leave a Reply

Your email address will not be published. Required fields are marked *