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
buy me a soda if this post prevented any headaches! Another way to show your appreciation is to take a gander at these relative ads that I hope you'll be interested in:
Here are some similar posts that you may be interested in:
- LaTeX Laboratory Report Template with Many Examples
- Extract/Uncompress/Unarchive Almost Any File in Linux (tar, tar.gz, tar.bz2, gz, bz, zip, 7z, rar, etc…)
- How-To: Setup a Pre-Built VirtualBox Guest Image [Tutorial/Guide]
- Finding glibc and gcc Versions
- Fedora 12 Constantine on MacBook Aluminum 5,1 [Guide]