## 6.8 Generate a LaTeX fragment

If you work primarily with pure LaTeX documents, you may still find R Markdown useful. Sometimes it may be more convenient to write in R Markdown and convert the document to a LaTeX fragment, which can be included in 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 in another LaTeX document.