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.

Is there a way to insert a document within a document? The inserted code is fully .tex compliant and could be compiled as a document on its own.

I envision an article document, where inside the document, I show multiple beamer documents. The purpose of this is to demonstrate various beamer features and how they affect the final beamer presentation.

I would guess the code would look something like this,

\documentclass[article]
\usepackage{latexinsert} % hypothetical package

\begin{document}

\begin[frame = single]{insert_environment} % hypothetical environment name
%frame around the inserted document compiled from LaTeX code
\documentclass[article]
\usepackage{amsmath}

\begin{document}
Hello, world!
\begin{align*}
a^2 + b^2 = c^2
\end{align*}
\end{document}

\end{insert_environment}

\end{document}

Thanks for your assistance.

share|improve this question
    
Maybe look at the source code for the beamer manual for an implementation? –  Matthew Leingang Sep 24 '12 at 0:10
    
Look at the package docmute. It will allow you to have individually compilable tex documents which can be either inputed or includeded into your main document. –  R. Schumacher Sep 24 '12 at 0:17
add comment

1 Answer

up vote 10 down vote accepted

This sounds like a job for the standalone bundle. Note that I use the word 'bundle' because standalone represents both a documentclass and a package!

Let's say that you have a file framefile.tex that has the following code

\documentclass[beamer]{standalone}

\begin{document}

Hello, world!
\[
    a^2 + b^2 = c^2
\]
\end{document}

This file can be compiled on its own. Note that this file uses standalone as documentclass.

Now let's create your mainfile.tex which can input your framefile.tex

\documentclass{beamer}
\usepackage{standalone}

\begin{document}

\begin{frame}
    \input{framefile}
\end{frame}

\end{document}

Note that this file uses standalone as a package.

share|improve this answer
add comment

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.