2

I'm writing an article in LaTeX with theorem environments. Is it possible to create automatically one PDF file with whole article and in addition other PDF file only with theorems without the rest? Below I give an example file.

\documentclass{article}
\newtheorem{theorem}{Theorem}
\newtheorem{lemma}{Lemma} 

\begin{document}

\begin{theorem} 
This is theorem 1.
\end{theorem}

\begin{lemma}
This is lemma 2.
\end{lemma}

\begin{theorem}
This is theorem 3.
\end{theorem}

\end{document}
Mayers
  • 513
  • Probably a duplicate of http://tex.stackexchange.com/questions/5228/can-one-tex-file-output-to-multiple-pdf-files or http://tex.stackexchange.com/questions/162042/multiple-pdf-generation-with-one-tex-file or http://tex.stackexchange.com/questions/74243/automatically-create-two-pdf-output-files-from-one-tex-file (this one already duplicated, but it has interesting answers) – Rmano Mar 21 '17 at 19:32

1 Answers1

1

Here's an approach with the multiaudience package.

By commenting the %\def\CurrentAudience you control which parts are compiled. The - (minus) in \begin{shownto}{-,myNotATheorem} ivnerts the argument(s).

According to the manual you can also use this to define different versions in batch files, like pdflatex "\def\CurrentAudience{SomeAudienceTag}\input{file}".

\documentclass[preview,border=2mm]{standalone}
\newtheorem{theorem}{Theorem}
\newtheorem{lemma}{Lemma} 

%% The important package here
\usepackage{multiaudience}
% Define the possible audiences
\SetNewAudience{myNotATheorem}
\SetNewAudience{SomeThingElse}

%% Comment / Uncomment at free will
%\def\CurrentAudience{myNotATheorem}
\def\CurrentAudience{SomeThingElse}

\begin{document}

\texttt{\textbackslash CurrentAudience:} \textbf{\CurrentAudience}

\begin{theorem} 
This is theorem 1.
\end{theorem}

\begin{shownto}{-,myNotATheorem}
\begin{lemma}
This is lemma 2.
\end{lemma}
\end{shownto}

\begin{theorem}
This is theorem 3.
\end{theorem}

\end{document}

enter image description here


enter image description here


  • Thank you! I have one more question. To make what I want I have to write \begin{shownto}{...} and \end{shownto}. Is it possible to define something like function in preamble so that I won't have to write this and I could only write \begin{theorem} ... \end{theorem} and LaTeX will know that when I uncomment \def\CurrentAudience{myNotATheorem} it should compile only theorems? – Mayers Mar 22 '17 at 20:16
  • @Mayers I don't know. But with a decent text editor you can easily solve the problem with a simple search and replace :) – Dr. Manuel Kuehner Mar 22 '17 at 20:56