0

I'd like to be able to generate different versions of a document using some kind of print command inside an \ifthenelse statement. Here's an example of what I would like to do. I'd like to do it this way because my document is quite long and has many sections. I think it would be easier for me to do something like this rather than define all the text inside the \ifthenelse statement.

\documentclass{article}

\usepackage{ifthen}

\begin{document}

\newcommand{\docVersion}[1]
{
% normally, text would go where the commands \printA{} and \printB{} would go
    \ifthenelse{\equal{#1}{group A version}}{\printA{}}{}
    \ifthenelse{\equal{#1}{group B version}}{\printB{}}{}
}

% so here, I could define that I want group A's version
\docVersion{group A version}

% and only this would be printed
\printA{Some stuff for group A here.}

% and this would not
\printB{Some stuff for group B here.}

% and this would be printed also
Some stuff for both groups here.

\end{document}
4
  • Welcome to TeX.SE. There are various ways here (“Passing parameters to a document”). If true/false logic is enough, \newif can do (or etoolbox's \newboolean, etc.). If you want a conditional with more than 2 outcomes, \ifcase could come in handy (or expl3's \str_case:nnTF, etc.).
    – frougon
    Commented Mar 25, 2020 at 15:41
  • See also this answer and that one. Contrary to the above question, these are not focused on passing a parameter from the command line, which can be nice but is not part of your question.
    – frougon
    Commented Mar 25, 2020 at 15:49
  • The docstrip package can be used for deriving/generating several different .tex-files from a common .tex-source by means of tags that get placed into the common source-file and that denote into which derived .tex-file a tagged snippet of code goes. Besides this, the answers to the question Compile to PDF file with different name than the source might be of interest to you. My second answer to shared common text across many documents might be of interest, too. Commented Mar 28, 2020 at 9:35
  • In my answer to Collection of redefined commands a list of resources with information about the packages docstrip and doc is provided. The answer to Defining environment that can be turned on and off for different versions provides an example of how to derive a teacher's version and a student's version of a document from the same common .tex-input file. Commented Mar 28, 2020 at 9:40

0

You must log in to answer this question.

Browse other questions tagged .