LyX: Missing Title When Passing `ignorenonframetext` to Beamer

Passing ignorenonframetext as an option to Beamer causes it to ignore all text that is not inside a frame. It is useful when you want to add content for the article version of the presentation (or simply script lines for yourself) that would not show in the regular presentation. LyX puts the title elements outside any frame. Therefore, if you use ignorenonframetext, you end up missing the title frame. The solution is to manually wrap the title block (the title, author, institute, etc.) in a frame and append maketitle to it. This will cause the title frame to be rendered correctly.

Creating a Hebrew Document in LyX 2.1 with XeTeX

This post complements the basic LaTeX template I gave yesterday for typesetting Hebrew with XeTeX. I’ll walk through the (short) list of steps needed to configure LyX for XeTeX.

Prerequisites

  • LyX 2.1 or later (I’ve also tested the development version of 2.2). I had very limited success with LyX 2.0, so you should probably avoid it.
  • XeTeX – I’ve tested with version 3.1415926-2.4-0.9998, which comes with TeXLive 2012, but I guess any recent version will do.
  • The polyglossia and bidi packages. Again, I’ve used the versions that come with TeXLive 2012.
  • Good TrueType Hebrew fonts. I recommend Culmus 0.121 or newer. You may also try using the fonts that come with your operating system; they might work as well.

Setting up the document

Create a new document and open the settings dialog (Document -> Settings...).

  1. Pick a suitable Document class. I recommend “KOMA-Script Article,” but “Article” works just as well. Avoid “Hebrew Article,” as it is broken under XeTeX.
  2. Under Fonts, check the box next to `Use non-TeX fonts (via XeTeX/LuaTeX)` and select suitable fonts:
    • Roman: Frank Ruehl CLM. David CLM is also a good choice, with a somewhat better italic variant.
    • Sans Serif: Simple CLM.
    • Typewriter: Miriam Mono CLM.
    • There is no need to change the Math font.
  3. Under Language, select Hebrew as the document’s language.

That’s basically it. You can now write your document and compile it. I would suggest saving these settings as defaults (via “Save as Document Defaults”) or saving the document as a template so you won’t need to repeat these steps.

Writing in English

To insert English text into your Hebrew document, you need to change the current language. The easiest way to do so is to create a keyboard shortcut for it:

  1. Go to Tools -> Preferences -> Editing -> Shortcuts
  2. Type “language” under “Show key-bindings containing:”.
  3. Select “language” under “Cursor, Mouse and Editing Functions” and click “Modify” to set a keyboard shortcut (F12 is traditionally used for this).

Now you can toggle the current language between English and Hebrew by simply pressing F12.

Remark about Fonts

It is preferable to use fonts that provide both Hebrew and Latin scripts, as otherwise there might be significant style differences that make the document look weird. It is possible to set a different font for Hebrew and Latin, but care needs to be taken to match styles. To do so, add the following lines to the Preamble:

newfontfamilyhebrewfont[Script=Hebrew]{David CLM}
newfontfamilyhebrewfonttt[Script=Hebrew]{Miriam Mono CLM}
newfontfamilyhebrewfontsf[Script=Hebrew]{Simple CLM}

Number Exercises Separately in LyX

Say you’ve got a document with a bunch of exercises and a few lemmas. You may want the exercises numbered separately from the lemmas and theorems, unlike LyX’s default behavior. This can be achieved by redefining xca, the environment LyX uses for exercises. Add the following to your LaTeX preamble:

letxca@undefined
theoremstyle{plain}
newtheorem{xca}{protectexercisename}

LyX will still display the incorrect numbering, but the output will be correct nonetheless. The first line undefines LyX’s definition of xca, then we set the style to match the old one, and we redefine xca, this time without a reference to the theorem counter.

Expectation Symbol in LaTeX

After looking for a built-in expectation symbol in LaTeX, and coming up with none, I’ve defined one. Just add:

% Expectation symbol
DeclareMathOperator*{E}{mathbb{E}}

to your LaTeX preamble, and you’re done. You’ll also need to add usepackage{amsmath}, or in LyX, tick “Use AMS math package” under Document->Settings->Math Options.

Using the starred version of DeclareMathOperator makes sure subscripts go beneath the symbol in display mode.

lyxframeend Undefined when Using Beamer with LyX

I’m using LyX for the first time with Beamer. Making the title page was smooth. But when I tried adding a new frame (using BeginFrame), I was confronted with the following error

 lyxframeend
                 {}lyxframe{Outline}
The control sequence at the end of the top line
of your error message was never def'ed. If you have
misspelled it (e.g., `hobx'), type `I' and the correct
spelling (e.g., `Ihbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

After comparing my document to example (working) Beamer documents, I’ve found out that you must have an EndFrame command after your last frame. Too bad it wasn’t documented anywhere I looked, as this little thing drove me crazy.

Displaying Non-Builtin Math Macros in LyX

I believe LyX is a great tool for writing LaTeX documents. It makes writing formulas very easy, and it allows you to see the formula as you are writing, as opposed to seeing only LaTeX code. However, LyX doesn’t support every LaTeX package and the macros it defines. Sure, it doesn’t stop you from using these macros in your formulas, but they don’t display nicely; you see the name of the macro instead of a schematic preview.

While LyX doesn’t support many of the great packages out there, like mathtools (which I really hope it will someday), you can add some support to your documents. At the beginning of the document, insert a comment via Insert->Note->Comment. Inside the newly created comment, insert a math macro via Insert->Math->Macro. In the name part, put the name of the command you want to add support for. In the second box (captioned LyX), use existing LyX commands to mimic how the macro will look. For example, this is what it looks like for the coloneqq macro (from the great mathtools package):
math-macro

After adding the math macro in the comment, when you use the macro inside formulas, it will display nicely:
math-macro2

A little explanation of how things work: when you define a math macro in LyX, LyX does two things:

  1. Inserts LaTeX code to create the macro.
  2. Displays the macro nicely when editing the document.

While the latter is desirable, the former is problematic. If LyX inserts LaTeX code to define the existing macro, it will cause errors. So when you put the LyX macro in the comment environment, the code LyX generates gets ignored, and only the second, desirable, outcome is achieved.

Fixing Numbering Direction for Hebrew Text in LyX

On Monday, I submitted a patch to the LyX developers mailing list with a fix for the numbering direction in Hebrew text. In Hebrew text, the dot appeared before the numbering symbol instead of after it, as it should.
before-fix
This behaviour has been this way for years (at least as long as I can remember).
Continue reading Fixing Numbering Direction for Hebrew Text in LyX