Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to add code listings to LaTeX document using verbatim environment

📅 2012-Dec-15 ⬩ ✍️ Ashwin Nanjappa ⬩ 📚 Archive

[caption id="attachment_2997" align="aligncenter" width="255"][Code displayed using verbatim environment](http://codeyarns.wordpress.com/2012/12/15/how-to-add-code-listings-to-latex-document-using-verbatim-environment/20121215-verbatim/#main) Code displayed using verbatim environment[/caption]

Source code listings can be displayed in a LaTeX document using the verbatim environment like this:

\begin{verbatim}
int main()
{
    return 0;
}
\end{verbatim}

The text inside the verbatim environment is typeset using typewriter font. Also, all the characters are printed, including whitespace.

Tried with: MikTeX 2.9 and Windows 8 Pro