2

Continuing experimenting with conditional text, I am getting a code with a number of options: some dialogs in english are translated, some other options (not shown in the MWE) enable the document be compiled with or without the graphics. In order to enable an final conversion into a docbook format, I have also made a macro to eliminate explicit reference to chapters, and page numbers. There are other variants. The number of options begins to be a problem for each revision. I would like to be able to generate (compile) most variants sequentially without a manual change of parameters in the code. I have just discovered makefiles, and I am wondering if a makefile could be used to generate all the different variants of the document and how. I have considered locating the lines of code containing the options that need to be changed in subfiles and would be optionnally used for compilation. What would be the best approach ?

\documentclass[a5paper, 11pt,oneside]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}% 
\usepackage{ifthen}
\usepackage[english, frenchb]{babel}% Pour franciser LaTeX

\def\pagenum{n} %page numbering  {n} to eliminate

\makeatletter
\ifthenelse{\equal{\pagenum}{n}}{\let\ps@plain\ps@empty}{}%first page of chapters
\makeatother
%====================
\def\lang {ef} %variable used for conditional text e=english, f=french, ef=english with footnotes
\newcommand{\CondText}[2]{%
\ifthenelse{\equal{\lang}{e}}{{\selectlanguage{english}\emph{#1}}}{}%
\ifthenelse{\equal{\lang}{ef}}{{\selectlanguage{english}\emph{#1}}%
\footnote{\selectlanguage{french} #2}}{}%
\ifthenelse{\equal{\lang}{f}}{{\selectlanguage{french} #2}}{}%
}%

\begin{document}
\ifthenelse{\equal{\pagenum}{n}}{\pagestyle{empty}}{}%
\ifthenelse{\equal{\pagenum}{n}}{\chapter*}{\chapter}{L'auberge}

\CondText {--- Sir, the manager needs to see you before you go !}{--- Monsieur, le patron veut vous voir avant votre départ !}\medskip

Some text in french\dots{}
    \end{document}
Yves
  • 2,825
  • I'd do the following. 1) Create a custom class on top of book. 2) Declare all the options of class book and those of the packages you load as options of your custom class. 3) Inside your custom class, move the options around to the corresponding class or package (as explained here). 4) Create a makefile using Martin Scharrer's trick. – jub0bs Nov 19 '13 at 17:39
  • Neil Olver's trick may prove useful too. – jub0bs Nov 19 '13 at 17:55
  • Many options are shown in the previous discussions and none seems universal. As my current problem is simple, and considering I am a beginner, I have elected to use the "optional" package, called by: pdflatex "\def\UseOption{number,f} \input{MWE.tex}" with the changes of code below: \usepackage[nonumber, f]{optional} \opt{nonumber}{\def\pagenum{n}} \opt{number}{\def\pagenum{y}}

    \opt{f}{\def\lang {f}} \opt{e}{\def\lang {e}} \opt{ef}{\def\lang {ef}}

    – Yves Nov 19 '13 at 20:08

0 Answers0