I've got a standalone document that uses siunitx
:
% subdocument.tex
\documentclass{standalone}
\usepackage{siunitx}
\begin{document}
\SI{10}{\kilo\newton}
\end{document}
I'd like to include this standalone document as a sub-document in a different document, using the standalone
package. Because I don't want to manually keep track of which packages are needed for the sub-document, I want to use the subpreambles=true
option of standalone
:
% main.tex
\documentclass{article}
\usepackage[subpreambles=true]{standalone}
\begin{document}
\input{subdocument.tex}
\end{document}
However, if I do that, I get an error message:
! Undefined control sequence.
<argument> \l__siunitx_option_deactivate_clist
I could fix this by loading siunitx
in main.tex
, but I hope that there is a different way around this.
Here's a MWE:
\documentclass{article}
\begin{filecontents}{subdocument.tex}
\documentclass{standalone}
\usepackage{siunitx}
\begin{document}
\SI{10}{\kilo\newton}
\end{document}
\end{filecontents}
% This works (loading siunitx only in the main document)
%\usepackage[subpreambles=false]{standalone}
%\usepackage{siunitx}
% This doesn't (loading siunitx in the sub-document), but it would be nice if it did:
\usepackage[subpreambles=true]{standalone}
\begin{document}
\input{subdocument.tex}
\end{document}
\AtBeginDocument
are likely to fail here. I seesubpreambles=true
for defining macros used in the subdocument, not for loading packages. – egreg Jun 19 '13 at 20:17standalone
explains, the packages loaded in the subpreambles are stored in an auxiliary file and they are eventually loaded using\AtBeginDocument
. But when\@begindocumenthook
is executed,\AtBeginDocument
is redefined to be\@gobble
, so no code those packages want to delay at begin document sees the light. – egreg Jun 19 '13 at 20:25\usepackage{standalone}
in combination with\unexpanded
siunits
. Therefore, you need to loadsiunitx
within the main document – Rico Jun 20 '13 at 7:14standalone
then use theetoolbox
\AtEndPreamble
rather than\AtBeginDocument
? – user4686 Nov 7 '13 at 9:35\AtBeginDocument
to\@gobble
? – kiss my armpit Nov 8 '13 at 20:45