## 5.10 Generate a LaTeX fragment

If you work with pure LaTeX documents primarily, you may still find R Markdown useful, because sometimes it may be more convenient to write in R Markdown and convert the document to a LaTeX fragment, which can be included into other LaTeX documents.

When you render an Rmd document to LaTeX, it generates a full LaTeX document that includes the \documentclass{}, \begin{body}, and \end{body}. A LaTeX fragment is basically the body of a full LaTeX document. To render a LaTeX fragment, you may use the latex_fragment output format, e.g.,

---
output: latex_fragment
---

This will render a .tex file, e.g., foo.Rmd will render foo.tex, and you can use \input{foo.tex} to include this fragment into another LaTeX document.