The MWE below attemps to define a \newif
within a \ifdefined
. This works fine, except when the file is loaded the second time.
As it is below generates the following error message:
Incomplete \ifdefined; all text was ignored after line 1.
However if you comment out the \newif
works as desired.
Question:
How do I declare the \newif
within the \ifdefined
?
MWE:
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{MyHeader.tex}
\ifdefined\MyHeaderAlreadyIncluded\else
\def\MyHeaderAlreadyIncluded{}%
\newcommand{\SomeCommand}{some command}%
\newif\ifDTLnewdbonload%
\fi
\end{filecontents*}
\begin{document}
Lorem ipsum
\input{MyHeader.tex} \SomeCommand.
\input{MyHeader.tex} \SomeCommand.
\end{document}
\expandafter\newif\csname ifDTLnewboload\endcsname
; but there are better ways. – egreg Feb 3 '13 at 22:31