# How to combine two LaTeX files

I have two separate LaTeX pages: one is a report and one is a beamer. I need to submit them as a single pdf and there should be consistency between the files, e.g. if the report finishes in the 50th page, the beamer should start from the 51st page. Can someone please help me with that?

Any help would be greatly appreciated!

-
If you are not going to update or files, you can set up the page number of your beamer pdf using \setcounter{page}{xxx} and them you can join both pdf files (in linux, using pdftk for example). But if you need to do this many times, you can try to use combine package. –  Sigur Sep 9 '12 at 0:11
Hi Thanks for your quick response. I am afraid I am not too familiar with linux. So, I would prefer the combine package. Can you please briefly describe how to use it. For example let's say I have two latex files called dissertation (in report class) and poster (in beamer class). Can you please tell me how to combine them using the combine package? Cheers Gunal –  Günal Sep 9 '12 at 0:55
–  Sigur Sep 9 '12 at 1:03
Cheers for the link. I am afraid they have not been useful for me because they work for the files that are in the same class. My classes are beamer and report. So, I still need help. Cheers Gunal –  Günal Sep 9 '12 at 14:39

## Notes:

Please edit the following for those who know how to add the resumed page numbers for imported beamer slides.

% this file name is main.tex just for easing our discussion!
\documentclass{article}

\usepackage{filecontents}
% report input file
\begin{filecontents*}{myreport.tex}
\documentclass{article}
\usepackage[a4paper,margin=3cm]{geometry}
\usepackage{blindtext}
\begin{document}
\Blinddocument
\end{document}
\end{filecontents*}

% beamer input file
\begin{filecontents*}{mybeamer.tex}
\documentclass{beamer}

\begin{document}
\begin{frame}{Hello World}
I am the first frame!
\end{frame}

\begin{frame}{Hello Universe}
I am the second frame!
\end{frame}

\end{document}
\end{filecontents*}

\immediate\write18{pdflatex -shell-escape myreport}
\immediate\write18{pdflatex -shell-escape myreport}
\immediate\write18{pdflatex -shell-escape myreport}

\immediate\write18{pdflatex -shell-escape mybeamer}
\immediate\write18{pdflatex -shell-escape mybeamer}

\usepackage{pdfpages}
\begin{document}
\includepdf[pages=-]{myreport}
\includepdf[pages=-,landscape]{mybeamer}
\end{document}


## Demo Scenario:

The codes between % start simulating your situation and % stop simulating your situation are intentionally added just for simulating your situation in which you have 2 PDF files. The codes will produce both files on the fly before merging them. If you want to compile it for a demo (because it does not use your own PDF files), compile it with pdflatex -shell-escape main.tex.

See the following if you want to use your own PDF files!

## Real Scenario:

In your real scenario, please remove the codes between those tags, edit the file names for the following codes

\includepdf[pages=-]{myreport}
\includepdf[pages=-,landscape]{mybeamer}


and compile it with normal usage which does not need -shell-escape. In other words, your real main input file becomes

% this file name is main.tex just for easing our discussion!
\documentclass{article}
\usepackage{pdfpages}
\begin{document}
\includepdf[pages=-]{myreport}
\includepdf[pages=-,landscape]{mybeamer}
\end{document}


and you need to compile it with pdflatex main.tex wheere main.tex is the file name of the main input file to merge your 2 PDF files.

-
Why you are fond of CW?. Don't tell that you want to avoid rep ;) –  Harish Kumar Sep 9 '12 at 16:31
@HarishKumar: I want me and others who edit my answer to avoid getting reputation points. :-) –  kiss my armpit Sep 9 '12 at 16:35
I could not make it work I am afraid. Can you please double check? –  Günal Sep 9 '12 at 23:40
It produces the error LaTeX Warning: Overwriting file ./myreport.tex' . I do not know to compile it with pdflatex -shell-escape filename.tex. Can you please give a bit more details? –  Günal Sep 10 '12 at 12:37
pdfpages is pretty nice, but it kills all the hyperlinks inside individual pdf's which is a pity. (I have the same task as OP.) –  Artem Pelenitsyn May 20 '13 at 9:13

I think the easiest way is to use a tool like PDFcreator (on windows systems) to build one pdf file. First compile your report and check the generated page numbers (let's say 50 pages). Then compile your beamer file after including \setcounter{page}{51}.

Now you can add with PDFcreator` both files to one.

-