8
Jun

Including a Program Source File in LaTeX [Tip]

This is a command within LaTeX that I forget constantly and I always lose the resource from where I learned about it. So, I’m documenting it here so that I can find it later on when I need it. I also figured it might help somebody else out there looking for the same thing.

lstset{language=[ISO]C++,tabsize=3}
lstinputlisting{Lab6.cpp}

Basically, what this little code snippit does is import a source code file and inserts it into the final document. It’s a lot easier than copy/paste and it has a lot of formatting options associated with it. Just check out the lstset command manual or this guide here or this guide here (LaTeX wikibook). Be sure to include the listings package with this declaration before the main document: usepackage{listings}.

Feel free to donate if this post prevented any headaches! Another way to show your appreciation is to take a gander at these relative ads that you may be interested in:


There's 0 Comment So Far

Share your thoughts, leave a comment!