3

I need to include a letter in my report, and I'm doing this using the pdfpages package. I'd like it so that when my report, report.tex goes to compile and include letter.pdf, it first compile letter.tex and then, after having compiled letter.tex, include letter.pdf into the report. I've thought of writing a script to do this, but the solution needs to be cross-platform (the report is being worked on by five people using both Linux and Windows).

Thanks.

3

2 Answers 2

2

May be something like this using --shell-escape or --enable-write18 for pdflatex (Assuming your letter-test.tex files are safe to run) and \immediate\write18{...}

letter-test.tex

\documentclass{article}
\begin{document}
This is the letter.
\end{document}

report-test.tex

\documentclass{article}
\usepackage{pdfpages}
\usepackage{mwe} % http://www.ctan.org/pkg/mwe
\immediate\write18{pdflatex letter-test}
\begin{document}
This is the report with figure.
\begin{figure}
\centering
\includegraphics{example-image-a}
\end{figure}
\includepdf{letter-test}
\end{document}
2

I use arara to do this instead of a script

\documentclass{article}
\usepackage{pdfpages}
\begin{document}
    \clearpage
    \includepdf[pages={-}]{docA.pdf}

    \clearpage
    \includepdf[pages={-}]{docB.pdf}

    \clearpage
    \includepdf[pages={-}]{docC.pdf}
\end{document}

% arara: pdflatex: { files: [ docA.tex ] }
% arara: pdflatex: { files: [ docB.tex ] }
% arara: pdflatex: { files: [ docC.tex ] }
% arara: pdflatex

I go one step further and have written an arara rule which calls arara. The arara directives in my main document looks like

% arara: arara: { files: [ docA.tex ] }
% arara: arara: { files: [ docB.tex ] }
% arara: arara: { files: [ docC.tex ] }
% arara: pdflatex

while the directives in docA.tex might look like

% arara: pdflatex: { files: [ docA.tex ] }
% arara: biber: { files: [ docA.bcf ] }
% arara: pdflatex: { files: [ docA.tex ] }
% arara: pdflatex: { files: [ docA.tex ] }
2
  • +1 for arara, however: is it part of TexLive / MikTex? I kind of doubt that the average Windows user will be able to install and use it.
    – Daniel
    Commented Oct 17, 2013 at 14:23
  • @Daniel it is included with TexLive and installation on MikTeX doesn't seem that hard. Running it is no harder than running pdflatex from the CLI and some LaTeX editors will let you add it as a shortcut.
    – StrongBad
    Commented Oct 17, 2013 at 15:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .