# Outsource some text fragments

I have to type many books in Latex, where some chapters are quite similar to each other. My idea was to do one chapter in a directory and outsource the differences in a subdirectory where the main file is.

like this:

  CONTENT
|
|
|---Book1
|---differences
|
|---Book1
|---differences
|


The several book files would include the content file, while the content file includes the differences file.

My question now is: is it possible to NOT include the whole differences file? so I could say in the contents file:

 ...some text...
\include code-fragment 1 from differences
...some other common text
\include code-fragment 2 from differences


so I would not have to make plenty differences files for everything that is not common.

I hope my question is clear :) Many thanks

Thanks for the idea, WillAdams, it didn't work at first (maybe I made a mistake?), but if I put it the other way around it works:

The main file then looks like this:

  \documentclass[]{article}
\usepackage{etoolbox}

\newtoggle{one}\togglefalse{one}
\newtoggle{two}\togglefalse{two}
\begin{document}
.1. ..some text...\\

\toggletrue{one}
\input{code-fragment}
\togglefalse{one}

2. ...some other common text\\

\toggletrue{two}
\input{code-fragment}
\togglefalse{two}

\end{document}


and the file code-fragment:

  \iftoggle{one}{
different text to appear under 1'
}{}

\iftoggle{two}{
different text to appear under 2'
}{}

• I always manage to mess up the simple binary stuff --- pasted stuff in the wrong order I guess --- glad you got it working. – WillAdams Aug 19 '13 at 1:19