LyX with LaTeX

3 minute read

I really like the program LyX. It’s a front-end to LaTeX. And yes, those capitalizations are intentional. You see, sometimes when nerds write programs, they think they are being very clever when they name them. You should also realize that nerds define “cleverness” often as self-recursive acronyms, or acronyms that negate themselves. These may have been amusing to some at some point in the past, but now they are actually very tiresome, even to other nerds such as myself.

But I digress.

When you write a document in LyX, it’s like being halfway between Microsoft Word and LaTeX.

With LaTeX, you have an excellent type-setting program that makes the most beautiful equations, and is great for complicated documents that involve structure. For instance, section numbering, reference numbering, basically any numbering is automatically done by LaTeX. So if you insert an extra reference somewhere in your document, for example, it will automatically be added and numbered in the proper place in your Bibliography. It all works beautifully. The only problem is, when you write your document in LaTeX, you feel like you’re writing code. The reason for that is that you basically are writing code, the LaTeX code, most probably in a text editor. This always struck me as the wrong environment for writing fluid English. To write well, the aesthetics of the prose are important, and I always feel the aesthetics of a text editor are much too Spartan to have a positive influence.

With Microsoft Word, you see your text as you type it in a somewhat pleasant way, but the document structure aids (i.e. renumbering) that LaTeX intrinsically takes care of are very difficult to do. It is possible to have logical structure in the Word document, but very difficult. At every turn Word tempts you to just type in the literal numbers yourself instead of trying to understand Word’s arcane way of handling auto-renumbering. It really is a pain and requires self-discipline to make Word handle things in a professional manner. And for God’s sake, never try to make a floating figure in Word. If you edit your document after placing a floating picture, it will often fly in a very spectacular way off-margin or to another page. I am not lying.

Enter LyX. When editing a document, it appears as though you are looking at a very simple web page. This is nice enough to give you a feel for how your text will look. But it is not an exact representation of the finished product. To see the beautiful results of the LaTeX text formatting (which looks much better than a Word document) you have to “push the button” that generates one of many final forms of your document (PostScript, PDF, DVI, etc.). And with LaTeX, changing the final look of your document in complex ways (two-column vs. one-column, figures interspersed through the document vs. all figures at the end) can be accomplished by one line of text or by a GUI pull-down menu in the LyX interface.

The other great thing, is that often a LaTeX style file is available if you’re writing for a journal. If it is already included in the stock LaTeX/Lyx installations, all you have to do is select it, and then all margins, fonts, fontsizes, styles will automatically be set and you don’t have to worry about setting them yourself. For me, the IEEE journals style file is already supported in both programs.

Where things get tricky is if you have an external style file that you need to integrate into LyX that isn’t part of the default installation. For this, you’ll have to follow directions to add the document class to LaTeX first. Then, you’ll have to whip up a LyX template (which can usually be done by copying another template in the LyX distribution.) Then you’ll have to “reconfigure” LyX by selecting Edit -> Reconfigure in Lyx. It is all covered in the LyX help file entitled “Customization” but is still a little tricky. Basically the thing to remember is that the LaTeX document class defines the final rendering of the document, and what options are available, and the LyX template tells LyX where to find the LaTeX document class, and what options to make available to the user in Lyx with pretty GUI, and how to show the layout in LyX. Not so hard, but unfortunately if you’re doing it yourself it will require some experimenting.

Updated: