LyX: Missing title when passing `ignorenonframetext` to Beamer

Passing ignorenonframetext as an option to Beamer, causes it to ignore all the 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 to it \maketitle. 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 with XeTeX.

Prerequisites

  • LyX 2.1 or later (I’ve also tested with 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 those which come with TeXLive 2012.
  • Good TrueType Hebrew fonts. I recommend Culmus 0.121 or newer. You may also try and use 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 fine. 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 somewhat better italics 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 default (via “Save as Document Defaults”) or saving it as a template so you won’t need to repeat those steps.

Writing in English

To insert English text in 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. Write “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 which 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:

\newfontfamily\hebrewfont[Script=Hebrew]{David CLM}
\newfontfamily\hebrewfonttt[Script=Hebrew]{Miriam Mono CLM}
\newfontfamily\hebrewfontsf[Script=Hebrew]{Simple CLM}

Number Exercises Separately in LyX

Say you’ve got a document with a bunch of exercises and few lemmas. You may want the exercises numbered separately from the numbering of the lemmas and theorem, 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:

\let\xca\@undefined
\theoremstyle{plain}
\newtheorem{xca}{\protect\exercisename}

LyX will still display the incorrect numbering, but the output will be correct nonetheless. The first line, undefines the 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 theorems’ counter.

Expectation Symbol in LaTeX

After looking for a builtin 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 to tick “Use AMS math package” under Document->Settings->Math Options.

Using the starred version of \DeclareMathOperator makes sure subscripts goes 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’ve 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., `I\hbox'). 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’ve found as this little thing drove me crazy.

Displaying Non-Builtin Math Macros in LyX

I believe LyX is a great tool for writing LaTeX document. 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 it doesn’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 (caption LyX), use existing LyX commands to mimic how the macro will look like. 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 will use the macro inside formulas it will display nicely:
math-macro2

A little explanation 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’ve 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