TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use \begin{verbatim} and \end{verbatim} and have enclosed a Fortran code within it. (I am not using listing for a reason).

However, Verbatim is crossing the boundaries. enter image description here

How do I fix this?

My packages list is:

share|improve this question
Given that it is using a monospace font you either need to keep your fortran lines shorter than the number of characters that fit, or use a smaller font. eg put \small before the verbatim environment. – David Carlisle Mar 20 '12 at 15:24
Isn't there a possibility of it doing the linebreaks automatically? Its a long document, I don't want to sit and find each instance of this. – user10961 Mar 20 '12 at 15:25
verbatim means obey linebreaks so it turns off all line wrapping (which for fortran is a good thing as the code will be wrong if line wrapped without adding continuation markers) If you don't mind the code having invalid breaks then perhaps you want alltt rather than verbatim. I note you include listings which has a breaklines option,you didn't give your reason for not using listings – David Carlisle Mar 20 '12 at 15:30
How do I use alltt? – user10961 Mar 20 '12 at 15:39
it's part of the base latex distribution: input alltt package then use alltt env instead of verbatim, but you have to take more care of special characters in that case. You should have the package documentation on your system. – David Carlisle Mar 20 '12 at 15:45
up vote 3 down vote accepted

You are loading the listings package hence use key breaklines=true and \begin{lstlisting}...\end{lstlisting}.

\lstloadlanguages{[LaTeX]TeX, [primitive]TeX,fortran}
      showspaces=false,  % shows spacing symbol

a very long and totruous path which you can check to see if it breaks and where at the end of the line

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.