I am trying to use Martin Scharrer's nifty standalone package to put a Beamer animation into a standalone file. Here is a minimal example that demonstrates the error I am running into. The subfile, creatively named subfile.tex, that I am using is:


\newcommand*{\mytext}{Hello world!}

    \onslide<+->{\draw[red] (0,0) circle (3pt);}
    \onslide<+->{\draw[blue] (1,1) circle (3pt);}
    \onslide<+->{\draw[green] (2,0) circle (3pt);}
    \onslide<+->{\node at (1,2) {\mytext};}

On its own, this subfile compiles as expected.

The main file, named mainfile.tex, that I am using is:


%\newcommand*{\mytext}{Hello world!}

\begin{frame}{Main file}

When I try to compile this main file with pdflatex mainfile.tex, I get an error:

Runaway argument?
%\begin {standaloneframe}{Subfile}\begin {tikzpicture}\onslide <+->{\draw \ETC.
! File ended while scanning use of \sa@@endinput.

When I try a second run of pdflatex mainfile.tex, this runaway argument error disappears, but another error takes its place: Extra }, or forgotten \endgroup. I use X at the prompt to quit compilation after the error. Subsequent runs of pdflatex mainfile.tex continue to give this missing \endgroup error.

I have noticed a few things:

  • If I remove the subpreambles=true option and uncomment the two lines of copied preamble (\usepackage{tikz} and \newcommand*{\mytext}{Hello world!}), this modified main file compiles as expected.

  • However, if I keep the subpreambles=true option but uncomment the two lines of copied preamble, I get the same error when I try to compile. This suggests that something goes wrong in the subpreambles=true option.

Does anyone know what I am doing wrong here? In his comment below, Martin Scharrer mentions that multiple compilation runs work for him. I'm not sure why I seem to be unable to get multiple compilation runs to work for me.

  • 4
    The error only occurs at the first compiler run but disappears in the second and following compiler runs. This is definitively some bug in standalone. The beamer support isn't that great I have to confess. I will have a closer look at this. Feel free to report such issues at bitbucket.org/martin_scharrer/standalone/issues. – Martin Scharrer Sep 13 '12 at 17:07
  • 1
    If I call pdflatex -interaction=nonstopmode mainfile as the first run, then subsequent runs are performed regularly. – egreg Sep 14 '12 at 21:50
  • 1
    I now added a fix for this to the hg repository of standalone (bitbucket.org/martin_scharrer/standalone). The error is caused by a clean-up macro which should end the reading of the subfile preamble once \begin{document} is reached, but still has to discard everything in the same line of it. Having a % after it is actually a bad idea, but the real problem seems to be the changed \endlinechar. The new code resets it and discards anything verbatim to exclude any such issues. I will publish a bugfix release soon. – Martin Scharrer Sep 14 '12 at 22:59
  • I just uploaded v1.1b of standalone which fixes this issue. I will also close this question as "too localized" (in time) as it is local practice for package bugs. – Martin Scharrer Sep 15 '12 at 15:24
  • @MartinScharrer The v1.1b release of standalone works great! Thanks so much for your help! I wish I could give a bounty for your efforts. – Henry DeYoung Sep 15 '12 at 19:48