I am trying to use the \includeonlyframes option in a Lyx file created using the beamer template. but it is not working. ( I am trying this solution. https://tex.stackexchange.com/a/27354/38845 )

Here is what I did.

  • Added \includeonlyframes{mylable} to the document preamble in lyx.
  • Added a lable "mylable" to a frame (using insert-> label menu)
  • Expected behavior: only the frame labeled "mylable" should be displayed.
  • Actual behavior: Error "Error while previewing format"

There's a difference between "labeling a frame" and "inserting a label in a frame". The former should be passed as a key-value label=<label> using the optional argument of the frame environment/macro while the latter uses \label where needed. For \includeonlyframes to work as expected, you need the former not the latter. The following is taken from the beamer documentation (section 4.3.3 Ways of Improving Compilation Speed, p 30):

\includeonlyframes{⟨frame label list⟩}

This command behaves a little bit like the \includeonly command: Only the frames mentioned in the list are included. All other frames are suppressed. Nevertheless, the section and subsection commands are still executed, so that you still have the correct navigation bars. By labeling the current frame as, say, current and then saying \includeonlyframes{current}, you can work on a single frame quickly.

The ⟨frame label list⟩ is a comma-separated list (without spaces) of the names of frames that have been labeled. To label a frame, you must pass the option label=⟨name⟩ to the \frame command or frame environment.

You can achieve this in LyX by a right-click on the frame title and selecting to "Insert Short Title":

enter image description here

Now use the label=<label> inside the optional argument:

enter image description here

However, this is not enough. While the interface of LyX in this regard seems okay, the accompanying definition for using the optional argument isn't. Add the following to your preamble as well (Document > Settings... > LaTeX Preamble):


The above circumvents the intricate definition of \lyxframe, skipping beamer's overlay functionality. But, since you're using LyX, I don't think this is needed. Moreover, I don't think the actual code produced by the beamer layout (beamer.layout) in the preamble works as expected...

Now you can use


in your LaTeX Preamble and things should work fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.