Is it possible to nest files with the standalone package? I have something like the following:
In A.tex:
\documentclass{article}
\usepackage{standalone}
\begin{document}
\input{B}
\end{document}
B.tex:
\documentclass{standalone}
\begin{document}
\begin{table}
\input{C}
\end{table}
\end{document}
C.tex is
\documentclass{standalone}
\begin{document}
\begin{tabular}{ l l r r }
A & B & C & D
\end{tabular}
\end{document}
A and C compile fine, but when compiling B.tex I get errors starting with :
! LaTeX Error: Not in outer par mode.
and complaining from there.
Is what I'm trying to do — where A.tex includes B.tex includes C.tex — possible? Possible with floats?
Best Answer
Yes, you can nest
standalone
files, however, as with any other document which\input
sstandalone
files you need to load thestandalone
package also in this case.Another issue is that you can't use floats like
table
andfigure
environments in normalstandalone
files, because of the usedpreview
mode used. You need either switch it off using the class optionpreview=false
or redefine thetable
environment to not be a float.If you have a
\caption
you should use:instead, otherwise you get an error.
Update 2011/12/21
I now release
standalone
v1.0 which redefines floats by defaults to work insidestandalone
files. See thefloat
option in the manual for more details. See also Is it possible to use the figure environment with the standalone package?