Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a very long source file. I would like to prepare from this source two PDF files:

  1. PDF contains all of the source file

  2. PDF containing only a few, marked earlier parts of the source file.

How I should mark source file and how prepare main file in LateX, to achieve point 2?

share|improve this question
1  
Do you want to keep the same numbering for the second file as for the first? For instance, if in the second file you only have the figures 1, 5 and 10 do you want them to appear as 1, 5 and 10 or 1, 2 and 3 in the second file? Same question for the page numbers, tables, equations etc. –  Ludovic C. Jul 10 '13 at 9:53
    
Ludowic C. : No, I dont want to keep the same numbering. I want to have own numbering in the second. –  Ama Jul 10 '13 at 9:57
    
BTW: Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. –  karlkoeller Jul 10 '13 at 9:58
1  
Have a look at Producing different versions of a document which should be what you want. –  Martin Scharrer Jul 10 '13 at 10:04

1 Answer 1

In your long TeX input file (your source), use \ifsecret ... \fi to sandwich the secret parts that you want to either include or exclude. The common parts will always be included so don't sandwich them.

% filename.tex
\documentclass[preview,border=12pt]{standalone}
\newif\ifsecret
\begin{document}
common 1

\ifsecret
I have a top secret message here.
\fi

common 2
\end{document}

Make a batch file as follows.

pdflatex -jobname=secret-included "\AtBeginDocument{\secrettrue} \input{filename}"
pdflatex -jobname=secret-excluded "\AtBeginDocument{\secretfalse} \input{filename}"

The following simulates your problem.

% compile with pdflatex -shell-escape

\documentclass[preview,border=12pt]{standalone}
\usepackage{filecontents}

\begin{filecontents*}{filename.tex}
\documentclass[preview,border=12pt]{standalone}
\newif\ifsecret
\begin{document}
common 1

\ifsecret
I have a top secret message here.
\fi

common 2
\end{document}
\end{filecontents*}

\usepackage{graphicx}
\begin{document}
\immediate\write18{\unexpanded{pdflatex -jobname=secret-included "\AtBeginDocument{\secrettrue} \input{filename}"}}
\immediate\write18{\unexpanded{pdflatex -jobname=secret-excluded "\AtBeginDocument{\secretfalse} \input{filename}"}}
Done, secret-included.pdf and secret-excluded.pdf have been generated!

\fbox{\includegraphics[width=.5\linewidth]{secret-included}}%
\fbox{\includegraphics[width=.5\linewidth]{secret-excluded}}
\end{document}

enter image description here

share|improve this answer
    
I want include in 2 only small part of source file. In your example: only text between \ifsecret .... \fi –  Ama Jul 10 '13 at 14:29
    
@Ama: I cannot parse your sentences. Please use standardized English grammar. –  Please don't touch Jul 10 '13 at 14:36
    
@StiffJokes: I suppose @ama wants a kind-of only-secrets.pdf document; a file with only the secrets. –  Rmano Dec 17 '13 at 17:33
    
@Romano - yes, I want only-secrets.pdf document. Can you help me? –  Ama Jan 17 at 10:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.