# Include subsections depending on variables/ifthen [duplicate]

I am making a template for several books. I have a mainfile which includes the .tex files for my chapters. For each book, some chapters are always almost the same except for a few subsections.

How can I define a macro or something to only include this subsection under a specific condition?

It should be like this pseudo code:

  type=(A,C) <-- defined at the beginning of each book

\chapter{blabla}

if type=B, include: \section{first}
\section{second} <-- this is included always
if type=B,C, include: \section{third}
if type=A, include: \section{fourth}


so only sections second, third and fourth would appear in this particular case. Any idea how to realize that?

## marked as duplicate by Martin Schröder, Xavier, Werner, Thorsten, Stefan Kottwitz♦Jul 10 '13 at 6:19

• Why not simply a \includeonly{filename1,filename2,...} in the preamble? – Fran Jul 7 '13 at 2:03