[Tex/LaTex] How to include (print) Latex source code in generated pdf

pdfpdftex

I want to include the source code of my latex generated pdf file in the pdf file itself as printed text. Is there any way to do this?

Best Answer

if the purpose of this exercise is to make the source code visible to readers of the pdf file, say to document self-contained code examples, i've had excellent results with this simple approach.

\documentclass{article}
\usepackage{verbatim}

% your preamble

\begin{document}

% your text

\newpage
\verbatiminput{\jobname.tex}
\end{document}