3

I've read the following posts but I'm not sure they answer my doubt: Lyx nested environments; Normalizing nested environments for cleaner design (LyX).

I am using the AMS theorem environment, and I want to start a theorem immediately followed by an enumeration (ie. with no text in the first line following Theorem. In LaTeX, I would type:

\begin{theorem}
\begin{enumerate}
\item Bla Bla Bla
\end{enumerate}
\end{theorem}

I know you can nest environments in LyX, but it is not letting me leave the theorem environment empty. How can I have the Theorem show up, and immediately start the list?

1

2 Answers 2

4

Go to Document > Settings > Local Layout and enter the following:

ModifyStyle Theorem
    KeepEmpty 1
End

Then click on the "Validate" button, and then "OK". Now it should work as you want, but has a (likely undesired) consequence: when you are done writing your theorem, you can't get back to standard by just pressing Return a couple of times, because the KeepEmpty change means that we can enter empty lines in the Theorem environment. So to get back to Standard, you have to manually select the "Standard" layout from the drop-down box in the upper-left (or just use the shortcut alt + p, s).

For more information, if you are ready to jump down a rabbit hole, go to Help > Customization in LyX.

2

To have the enumeration start on a new line:

You can use \phantom{} to avoid the empty theorem text, while not providing an output.

Start the theorem environment, enter math mode and type \phantom, then press return. Then enter some text in the phantom box.

Move cursor to after the math mode box, and press Return for a new line. Choose enumerate layout in the dropdown, and press Tab to nest it in the theorem environment.

Having finsihed the enumeration, press Return twice to go back to the theorem environment, where you can the choose a different layout---e.g. proof.

In LyX, you get something like the following, with the phantomed not showing in the compiled.

enter image description here

Note: LyX has rich keyboard shortcut customization that we can use to insert the \phantom in a less fiddly manner: Go to Tools > Preferences > Editing > Shortcuts > New and in the Function field, insert math-insert \phantom{.} and assign it a shortcut.

Without new line:

Perhaps you are interested in an output identical to that of this MWE:

\documentclass{article}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}

\begin{document}
\begin{theorem}
\begin{enumerate}
\item Bla Bla Bla
\item Bla Bla Bla
\end{enumerate}
\end{theorem}
\end{document}

This compiles without the itemization starting on a new line:

enter image description here

To obtain this in LyX, you can label the theorem (Insert > Label) or insert an empty theorem title using an TeX code insert (Insert > TeX Code) with content []. The label option would look like this in LyX, and compiles as the above MWE:

enter image description here

3
  • Thanks for your answer. is there no alternative? This, while it does work, seems a bit fiddly. Commented Feb 18, 2020 at 16:21
  • @scottkosty provides an alternative :) I've edited my answer to include info on assigning a keyboard shortcut, as well as something that closer resembles the code you provided.
    – Rasmus
    Commented Feb 19, 2020 at 10:09
  • This answer is good and more general than the approach I gave, since you could use the shortcut for any similar layout without having to change anything in the local layout.
    – scottkosty
    Commented Feb 19, 2020 at 15:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .