Generalmanaged compilation

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
mrmag
Posts: 14
Joined: Mon Jul 21, 2008 1:55 pm

managed compilation

Post by mrmag »

Hello latex-community,

Is there any possibilities to manage the compilation of tex file? Depending on some conditions some parts of tex file are compiled and some parts are not, i.e.

condition1
Hello,
%
condition2
World!

If both condition1 and condition2 are true, then the output will be "Hello, World!". Otherwise, if condition1 is false and condition2 is true, then output is "World" etc.

Thank you in advance!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
T3.
Posts: 208
Joined: Fri Mar 14, 2008 12:58 pm

managed compilation

Post by T3. »

Code: Select all

\newif\ifcondition

\conditiontrue
\ifcondition
this will appear in your document
\fi

\conditionfalse
\ifcondition
this won't appear in your document
\fi
Cheers,

Tomek
mrmag
Posts: 14
Joined: Mon Jul 21, 2008 1:55 pm

Re: managed compilation

Post by mrmag »

Thanks, Tomek.
Ted
Posts: 94
Joined: Sat Jun 23, 2007 4:11 pm

managed compilation

Post by Ted »

Also consider the ifthen package and/or the comment package.
  • ifthen provides a flexible and easy-to-use way of adding conditional statements to your LaTeX. Its approach is more LaTeX'y than standard TeX if constructs. Additionally, it gives you other tools to make construction of these statements easier.
  • comment lets you define a slew of environments that can each be turned on and off at build time.
For example, when I write quizzes, I use the comment package to define parts of the quiz that should only show up in the quiz or the solution. I can then generate quizzes and solutions easily and keep everything all in one file.
-- Ted [home/blog]
Post Reply