# How to have each slide in a separate file, each compilable, then combine them

I would like to write each slide of a presentation into its own file, so that I can compile and view each slide, one at a time.
But, I still need to combine all of them to make my presentation.
What's is the way to do that?
I try the following, but it doesn't compile.
includedoc doesn't seems to be there in Beamer.

file: 1.tex

\documentclass{beamer}
\begin{document}
\begin{frame}
Content
\end{frame}
\end{document}


file: slide.tex

\documentclass{beamer}
\begin{document}
\includedoc{1}
\end{document}

-
I think what you want is the standalone class and package. –  Matthew Leingang Mar 14 '13 at 2:09
@GarbageCollector: I don't have time to work out an answer now, but I've skimmed the documentation and it mentions beamer a lot. So I believe it's possible. Also, the standalone author is a prolific beamer user (and contributor to this site) so I would not be surprised at all if this is one of his use cases. –  Matthew Leingang Mar 14 '13 at 2:26

## Method 1

The structure of LATEX documents doesn't allow one standalone document to be included as a part of another. docmutepackage tries to remedy this limitation and enables standalone documents to be imported with the standard \input and \include commands just as if they had no preamble.

Use docmute package in the main input file. docmute package will import everything between \begin{document} and \end{document} of the imported file (child.tex in the following example). You can still compile the child.tex as a standalone presentation.

\documentclass{beamer}
\usepackage{filecontents}
\begin{filecontents*}{child.tex}
\documentclass{beamer}
\begin{document}
\begin{frame}
Content
\end{frame}
\end{document}
\end{filecontents*}

\usepackage{docmute}
\begin{document}
\input{child}
\end{document}


## Method 2

Using standalone document class with option beamer for the child (imported) input file and using package standalone in the main input file.

\documentclass{beamer}
\usepackage{filecontents}
\begin{filecontents*}{child.tex}
\documentclass[beamer]{standalone}
\begin{document}
\begin{frame}
Content
\end{frame}
\end{document}
\end{filecontents*}

\usepackage{standalone}
\begin{document}
\input{child}
\end{document}


Note: using the first method seems to be simpler!

-
You've formatted the first paragraph like a blockquote; is it from some other documentation? –  Matthew Leingang Mar 14 '13 at 2:27
@MatthewLeingang: yes. but i edited a bit for clearness. –  Who is crazy first Mar 14 '13 at 2:28
What are you quoting from, then? –  Matthew Leingang Mar 14 '13 at 2:30
@MatthewLeingang: I quoted the first paragraph in the introduction section of docmute package. –  Who is crazy first Mar 14 '13 at 2:32
@GarbageCollector Thanks for the edit. –  Gonzalo Medina Mar 14 '13 at 13:05

One option, but I am not sure if this is exactly what you are after, would be to label the frames so that you can use \includeonlyframes; a little example:

\documentclass{beamer}

\includeonlyframes{one,three}

\begin{document}

\begin{frame}[label=one]
test frame one.
\end{frame}

\begin{frame}[label=two]
test frame two.
\end{frame}

\begin{frame}[label=three]
test frame three.
\end{frame}

\begin{frame}[label=four]
test frame four.
\end{frame}

\end{document}


Using the code above, only the two frames corresponding to the labels one and three will be shown.

Combining this idea with the use of \include (or \input), you then might write each frame contents in its own file; something like

\begin{frame}[label=two]
the frame contents...
\end{frame}


(notice, in particular that this subsidiary files have no \documentclass, nor \begin{document}, \end{document} commands); each of this files will then be saved in your current working directory as, for example, frameone.tex, frametwo.tex, framethree.tex, framefour.tex and then you can \include them in the desired order in your "main" document; for example:

\documentclass{beamer}

\begin{document}

\include{frametwo}
\include{framefour}
\include{framethree}
\include{frameone}

\end{document}


will show the four frames in the order two, four, three, one.

The following code

\documentclass{beamer}

\includeonlyframes{one,three}

\begin{document}

\include{frametwo}
\include{framefour}
\include{framethree}
\include{frameone}

\end{document}


will give you a two frame document showing the frames in the order three, one.

-