0

I have a main document defined of which I need to extract different versions. For example, in:

\section*{5\\animalia}
\vspace{\oneline}
\includegraphics[page={33}, trim=1cm 0 0 0]{\pdfsource}
\includepdf[page={34-37}]{\pdfsource}

the last line would be compiled only if I would run pdflatex with the argument AA. There should be around 20 different versions to prepare, so it would be great if I could compile all these in a batch, instead of preparing 20 different files. There are no common elements to select, so the lines from AA will all be different ones from AB or AJ. I had a look at \newcommand and \xparse, but I think I didn't find exactly what I needed. Any suggestions?

One other detail: the argument would also be passed to a text line at the start, namely:

\subsection*{ARGUMENT}

would print as AA. I think that is easy to do, but I couldn't also find a concrete example.

jmmmp
  • 1
  • 1

1 Answers1

2

If you compile the following with

pdflatex "\newcommand{\version}{KK}\input{filename.tex}"

you can test for the value of \version:

\documentclass{article}

\usepackage{ifthen}

\ifdefined\version
\else
\def\version{AK}
\fi

\begin{document}

\section{\version}

\ifthenelse{ \equal{\version}{KK} }{
    KK version  
}{
    other version
}

\end{document}
  • Thanks, that was what I needed. I'm now trying to implement a second version, where it can use an \or command - but from what I could see from the documentation, it doesn't work? \ifthenelse{\equal{\version}{AA}} {\includepdf[pages={45}]{\pdfsource}} {} seems to work, but \ifthenelse{\equal{\version}{AA}\or{BB}} {\includepdf[pages={45}]{\pdfsource}} {} and \ifthenelse{\equal{\version}{AA}\or{\version}{BB}} {\includepdf[pages={45}]{\pdfsource}} {} doesn't really, maybe I need to fiddle around with the brackets until I find the correct connection. – jmmmp Aug 15 '19 at 07:57
  • @jmmmp You could simply nest the ifthenelse, but I think this would be better as a new question – samcarter_is_at_topanswers.xyz Aug 15 '19 at 08:12
  • Ok, I got it. I wasn't repeating the whole condition: \ifthenelse{\equal{\version}{AA} \OR \equal{\version}{BB}} {\includepdf[pages={45}]{\pdfsource}} {} This is great, because it makes the code even much simpler. – jmmmp Aug 15 '19 at 08:30