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.

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 ] }
  • +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 Oct 17 '13 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 Oct 17 '13 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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