Introduction to LyX

Make working with LaTex easier by using the WYSIWYG editor LyX.
More LaTeX Commands and Previewing

With LyX, you can do most any formatting that is possible in LaTeX. Experienced LaTeX users will notice some LaTeX commands (e.g., \pagebreak) are missing. This is not really a drawback. You can always assign the TeX style to any portion of text, either by choosing the style from the list box or by pressing the TeX button. This tells LyX that the marked portion of text is to be taken as native LaTeX code, thereby allowing you to use even those LaTeX commands which cannot be reached by menu entry. Even hard-core LaTeX hackers can still be satisfied by saving their document in the usual LaTeX format by selecting File/Make LaTeX file. Although I admit that this file will not necessarily look the way it would if you had written the text directly in LaTeX, it opens up the possibility of hacking in anything you like and then running LaTeX directly on the file.

Although LyX is close to WYSIWYG, you might often still like a preview of your document. For this purpose, LyX offers both xdvi and ghostview. If both these programs are installed on your system, you can get a preview by selecting one of these two options from the file menu. The necessary background LaTeX commands (running LaTeX and, for the PostScript output, dvips) are done by LyX automatically, so you don't have to worry about whether all your files are up to date.

If you save text, the file is stored in the working directory you specify. But all the intermediate LaTeX-related output files (like .log, .dvi, .ps) are stored in a /tmp directory (the actual path can be specified in ~/.lyxrc), unless you explicitly instruct LyX to make a LaTeX file from your text.

Now that you have finished your first LyX (and perhaps your first LaTeX) document, it is time to drop a few notes on the customizations possible within LyX.


The first issue (which, in fact, is not really a customization of the application) is the template, which you may have noticed in the File menu (New from template...). You may already know the template notion from standard word processors, and in LyX it works just the same: a standard template document defining the basic settings like fonts, layout, etc. A prototype of such a template may be a letter (some letter templates are included in the LyX distribution), where you would set up basic items like your personal address, a standard opening and closing phrase and the layout. To create such a template, you don't have to do anything special—just start editing a new document with the desired settings. For those parts of the text which are not standard and are to be changed in each document using this template (an example in the letter case may be the recipient's address), you can type in any text, e.g., “recipient's name”. Look at the distribution's templates for other examples. After you finish, save this template to disk like any other LyX document.

Unlike other word processors, LyX does not use a special format for templates. Any LyX document can be taken to be a template and vice versa. As a template is also a “normal” document, saving a newly created template to disk also saves all the layout options currently selected. So, if you have created a letter template using a letter-sized sheet of paper, this page size is also saved to disk, as is all the font information, etc. If you do not want each of your later letters to use all these settings, you have two options:

  1. Leave the template file untouched. In this case, each time you create a new document using this template, you have to reset the settings to your specific needs after selecting the template. Remember, selecting a template is more or less like loading in a file; thus, all the settings saved in this file overwrite the current parameters.

  2. Change the template file by hand using any plain text editor. In this case, you can remove all the layout commands which you do not wish to be set by the template.

The more general you wish your template to be, the more likely you will choose option 2. On the other hand, this requires some knowledge and understanding of the LyX command language. It won't be too hard if you already know LaTeX, but for the first experiments you should perhaps leave the file untouched.


The last issue to be mentioned here is the ~/.lyx directory which is the place where real customization can take place. Again, leave the files as they are until you have become a bit more acquainted with LyX. In this directory, all your personal configuration files are stored. As long as your configuration and the global system's are the same, nothing is stored here.

You can, for example, store your preferred key-bindings. There are two standard bindings (PC-modern and Emacs), but you can also define your own key-binding scheme and tell LyX the file where it is stored. You can also define your own tool bar, various (LaTeX-related) commands, printing defaults, file defaults and the like. It would take quite a while to discuss all these options in detail, but I recommend taking a look at the file. Fortunately, all options are explained well, so it is easy to figure out where to do what.