LyX Talk Notes (for SPAMS)

Since it would run counter to the freewheeling, cheerfully heckling nature of SPAMS to expect people to take notes, I thought I'd better post them online. This is a list of things to be aware of when using LyX.

If you send me questions, I'll keep adding answers to this page after the lecture.


Fixing the amsmath theorem bug

Unfortunately, Athena computers currently have LyX 1.5.2 installed. This version has a bug with the amsmath layout. Luckily, there's an easy fix. You've encountered the bug if you get the following error message in your amsmath paper:

LaTeX Error: No counter 'thm' defined. 

To fix it, please save amsmaths.inc into the directory ~/.lyx/layouts. That's starting from your "home directory" ~, then going to the hidden directory .lyx (you may have to type name that and hit enter to get there), then going to the subdirectory layouts.

Now, restart LyX, and your amsmath file should work again.


Fixing the "language name in header" bug

This is actually not a LyX bug, but a bad interaction between babel, the multi-language support package, and the amsmath style. However, I run into it a lot, so I thought I'd mention it. The symptom is that you see "englishName of paper" in the running page headers (replace "english" by whatever language you're using). There's an easy workaround. Go to the very beginning of your document, make sure you're in "Standard" mode ("Alt-P S" for the keyboard users) hit Ctrl-L (insert LaTeX code), and paste this line inside the red box:

\let\languagename\relax % workaround for babel+amslatex bug

Watch out: Newer TeX distributions, such as TeX Live 2007-10, fix this bug. But, then this workaround causes LaTeX to hang!


How to...

  • Insert two Theorems, Definitions, etc. in a row: Finish your first theorem statement. Hit Enter to start a new paragraph. Switch to standard mode (Alt-P S). Hit Ctrl-L to create an empty LaTeX insert. Press the right arrow and Enter to leave the insert and make a new paragraph. Now you can mark this paragraph as a theorem.
  • Insert optional theorem title/credits: Put your cursor at the very beginning of the theorem environment. Then, hit Ctrl-L to insert LaTeX code, and in the red box type your optional title, in square braces. It will look like this:

    Theorem 1.1. [Main Theorem] The growth of telephone poles depends linearly on the amount of incident moonlight.

  • Edit matrices and tables: To make them, user Insert->Math->Matrix and Insert->Table, respectively. The following shortcut keys are useful, and work in both:
    Insert row:Alt-m w i
    Delete row:Alt-m w d
    Insert column:Alt-m c i
    Insert column:Alt-m c d
  • Customize/find shortcut keys: Look in the directory /usr/share/lyx/bind. If you install LyX on Windows, it'll be wherever you installed LyX. The files there specify keybindings. The most useful are: cua.bind and math.bind. The format is pretty self-explanatory; what might not be obvious is that "M-" means "Alt-", "C-" means "Ctrl-", etc.

    To customize the keybindings, create a file mine.bind in ~/.lyx/bind (on Windows, this directory will be somewhere under Documents and Settings). Put your custom shortcuts, in the same format, inside that file.

  • Use "Formatted reference" when inserting cross-references: Save the file prettyref.sty in the same directory as your LyX document. You may wish to edit this style file to add more ways to format references. E.g. you could make labels that start with "recp:" be referred to as "Recipe #".

Topics covered

  • Creating a document: import (does not work all that well), from template, from scratch.
  • Selecting and changing a document layout: article, amsmath, etc.
  • Setting margins, page styles, etc.
  • Typesetting your document (to DVI, PS, PDF, etc).
  • Environments (sections, theorems, etc). "Alt-P [space]" is an extremely useful keyboard shortcut.
  • Editing mathematics (shortcut keys make it very fast!)
  • Inserting pictures, tables, etc.
  • References and labels.
  • Citations and bibliography.
  • When LyX isn't enough: inserting TeX code, editing the preamble.
  • Using LyX to learn LaTeX.

[valid XHTML] [valid CSS]