GeneralLines of code go off the page

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
captain_thunder
Posts: 2
Joined: Thu Sep 24, 2009 12:20 am

Lines of code go off the page

Post by captain_thunder »

Sorry if there was a more appropriate forum for this, but I wasn't really sure.

I'm currently using the listings package, along with the lstinputlisting command to include source files containing code in a LaTeX document. However, some of the lines in the code are quite long, and run off the page.

Is there any way to make lstinputlisting use a smaller font size so all of the lines fit on the page? Or perhaps make the lines auto-wrap around? Or really any solution at all that doesn't involve editing the source files.

Thanks for the help.

Recommended reading 2024:

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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

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

Lines of code go off the page

Post by gmedina »

Hi,

you can use the breaklines option; refer to the package documentation for further information.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
captain_thunder
Posts: 2
Joined: Thu Sep 24, 2009 12:20 am

Re: Lines of code go off the page

Post by captain_thunder »

Thanks, that works perfectly.
Post Reply