[Tex/LaTex] One source, multiple outputs

automationcompilingorganisationprivacy

I built a CV using the kjh-vita LaTeX template (based on memoir and the template's custom stylings). I use(d) extensively end-notes via the enotez package. Then, I derive(d) a short version without the end-notes (all commented out, manually of course). Every now and then, I retouch various details either in the "full" version, or in the short one.

It'll be smart to keep one source from which to derive different versions (in the current case, the "full" and a short version, though I could make use of an option for a third version at some point).

The packages I use in the full version are:

\usepackage{org-preamble-xelatex} % as per the original template
\usepackage{fontawesome,marvosym,url} % \Mobilefone looks better than \faMobile
\usepackage{ebgaramond}
\usepackage{lastpage} % use in header for full version
\usepackage{xcolor}
\usepackage{csquotes}
\usepackage{enotez,fnpct,footmisc}
\usepackage{multicol} % end-notes in two-columns

Now, in the short version I'd like not to use some of the above, notably fnpct, enotez, multicol and footmisc. I'd like to silence all occurences of end-note markers (in-text and in the end). There are (and might be even) more changes (to come) that concern the content (text) itself (as asked/demonstrated in Multiple output pdfs with limited info in one).

Obviously, this is not a new question! Searching and reading the following related Q&As:

However, this information is a lot to read carefully. Any suggestions on where to start as a beginner?

Update

Just for the matter of completeness, I use http://www.scons.org/ and the following SConstruct for compiling the documents. It works straightforward (see also: https://tex.stackexchange.com/a/26573/8272).

# make sure scons finds tex executables:
import os
environment = Environment(ENV=os.environ)

# xelatex
environment['PDFLATEX'] = 'xelatex'

# target and source:
pdf_short_cv = environment.PDF(target='cv_nikalexandris_short.pdf', source='short_cv.tex')
pdf_full_cv = environment.PDF(target='cv_nikalexandris_full.pdf', source='full_cv.tex')

# make sure that the pdf is reloaded properly (e.g., in Skim)
environment.Precious(pdf_short_cv)
environment.Precious(pdf_full_cv)

Best Answer

Here's a schematic answer, since you seem as eager to learn the principles involved as you are in getting an answer.

For CVs, I like to break each section into discrete files, which you can then \input or not as needed. You could combine this with some boolean logic to determine if things get included or not. In the example below, you can see how to add the conditional clause into a macro definition and how to operate with \if-constructions directly.

So you need some "sections" in independ files:

% cv-associations.tex
\section{Associations}
\lipsum[1]

% cv-contact.tex
\section{Contact Info}
\lipsum[1]

% cv-education.tex
\section{Education}
\cvendnote{\lipsum[2]}%
\lipsum*[1]
\cvendnote{\lipsum[3]}%

% cv-outreach.tex
\section{Outreach}
\cvendnote{\lipsum[2]}%
\lipsum*[1]
\cvendnote{\lipsum[3]}%

% cv-presentation.tex
\section{Presentations}
\lipsum[1]

% cv-publications.tex
\section{Publications}
\lipsum[1]

% cv-teaching.tex
\section{Teaching}
\cvendnote{\lipsum[2]}%
\lipsum*[1]
\cvendnote{\lipsum[3]}%

Then you need the masterfile:

\RequirePackage{etoolbox}% etoolbox's \bool*-related commands work with normal \if-related commands
\providebool{fullCV}% default: false
%\booltrue{fullCV}
%
\documentclass{article}
\usepackage{fontspec}
\usepackage{fontawesome,url,marvosym}

% An example of how you might conditionally load packages
\iffullCV
\usepackage{ebgaramond}
\else
\usepackage{libertine}
\fi

\usepackage{lastpage}
\usepackage{xcolor}
\usepackage{fnpct}
\usepackage{enotez}
\usepackage{multicol}
\usepackage{footmisc}
\usepackage{csquotes}
\usepackage{lipsum}% just for dummy text

% for things you sometimes want to \input
\newcommand{\cvinput}[1]{%
  \iffullCV
  \input{#1}
  \else\fi}

% conditionally include \endnotes
\newcommand{\cvendnote}[1]{%
    \iffullCV
    \endnote{#1}%
    \else\fi}


\begin{document}

% regular \input files will always be included
\input{cv-contact}

\input{cv-education}

\input{cv-publications}

% \cvinput files will only be included if \fullCVtrue is active
\cvinput{cv-presentations}

\input{cv-teaching}

\cvinput{cv-outreach}

\input{cv-associations}

\iffullCV
\printendnotes
\else\fi

\end{document}

Now you can compile the file directly and simply uncomment the \booltrue line as needed. But the reason it's set up this way above the \documentclass line is so you can use the command line to compile both files with one command. Something like this, for example (assuming the filename is multioutputCV.tex):

xelatex -jobname=CVfull "\newif\iffullCV\fullCVtrue\input{multioutputCV.tex}" && xelatex -jobname=CVshort "\newif\iffullCV\fullCVfalse\input{multioutputCV.tex}"

(Compile twice, though, to get the endnotes in place for the full version.)

Should result in two files: CVshort.pdf and CVfull.pdf. You could now write a Makefile if you liked, but that is somewhat beyond the scope of this question.

Related Question