GeneralIncluding source code file

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
Onumis
Posts: 2
Joined: Sat Jun 12, 2010 1:19 am

Including source code file

Post by Onumis »

Hey

I'm doing a report for a work at univ.
I want to include the source code of various code files, namely from Flex and Yacc, which generates large files.

So I used the command:
\VerbatimInput[fontsize=\footnotesize,numbers=left]{parserYacc2.y}

but the result is terrible, as the text from this file goes beyond the margins

here's a link to an example:
verbatim.png
verbatim.png (64.19 KiB) Viewed 2084 times
Edit by localghost: No external links! Attachments go onto the forum server (see Board Rules).

how can i resolve this issue?
A friend told me to just copy & paste all the code inside the latex file under a
\begin{lstlisting}
...
\end{lstlisting}
environment that he gave me, but that is ridiculous imo...

Thx for your time!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Including source code file

Post by gmedina »

Hi,

you can use the \lstinputlisting to input stand alone files to your document; the listings package also offers automatic breaking of long lines. Refer to the package documentation for further details.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Onumis
Posts: 2
Joined: Sat Jun 12, 2010 1:19 am

Re: Including source code file

Post by Onumis »

It works really good, thx a lot!

Funny how I use that package for small snippets of code though the document, but didnt thought of using it for file including...
Post Reply