# [Tex/LaTex] How to do multiple calls to \includeonly

includeinput

Doing multiple call to include only as:

\includeonly{myfirstinclude}
\includeonly{mysecondinclude}


It is only including the last file called mysecondinclude by the last \includeonly call. It is useful to do multiple calls to \includeonly when you have all your \includeonly call listed and commented out.

\documentclass{article}

% How does 'filecontents' keep LaTeX parsing while temporarily stop writing output
% https://tex.stackexchange.com/questions/104159/how-does-filecontents-keep-latex
\usepackage{filecontents}

\begin{filecontents*}{myfirstinclude.tex}
myfirstinclude
\end{filecontents*}

\begin{filecontents*}{mysecondinclude.tex}
mysecondinclude
\end{filecontents*}

\begin{filecontents*}{mythirdinclude.tex}
mythirdinclude
\end{filecontents*}

% \includeonly{myfirstinclude}
% \includeonly{mysecondinclude}
% \includeonly{mythirdinclude}

\begin{document}

\include{myfirstinclude}
\include{mysecondinclude}
\include{mythirdinclude}

\end{document}


So when you want to include only one or some files, you just uncomment the desired line(s).

\includeonly{myfirstinclude}
\includeonly{mysecondinclude}
% \includeonly{mythirdinclude}


# Related Questions

For your specific use case you could use just one includeonly by putting each chapter on its own line:

\includeonly{%
myfirstinclude,
mysecondinclude,
mythirdinclude,
}


This way it is easy to comment out any of them, say, the second one:

\includeonly{%
myfirstinclude,
%mysecondinclude,
mythirdinclude,
}