I want to compile a document that uses the tcolorbox
package in two different ways:
- with the option
/tcb/lowerbox
set tovisible
, so that the lower part of thetcolorbox
environment is typeset - with the option
/tcb/lowerbox
set toignored
, so that the lower part of thetcolorbox
environment is not used.
At the beginning of the document there is the command
\tcbset{lowerbox=ignored}
which should be commented for the first case only.
Is it possible to control this behaviour from the command line when compiling the document, so that I do not have to edit the source explicitly in order to have the two versions of the document?
Here is a minimal working example. Let's say it is saved as test.tex
.
\documentclass{standalone}
\usepackage{tcolorbox}
%\tcbset{lowerbox=ignored}
\begin{document}
\begin{tcolorbox}
Upper part.
\tcblower
Lower part.
\end{tcolorbox}
\end{document}
Best Answer
You can add code to be executed when LaTeX scans
\begin{document}
. So long as\tcbset{lowerbox=ignored}
is executed before\begin{document}
, callingfor processing
<filename>.tex
should do. Read on if it doesn't.Not every setting can be passed this way; for instance, if package
foo.sty
sets its options at\begin{document}
, say calling\fooset{baz=true}
, addingto the command line would do nothing, because the order in which the calls are executed would be
which becomes
A way out is adding a layer, using
\AtEndPreamble
(requires\usepackage{etoolbox}
in the document):