# Verbatim going beyond borders

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.

How do I fix this?

My packages list is:

\documentclass[12pt,a4paper]{article}
\usepackage[latin3]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{listings}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}

-
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

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

\documentclass{article}
\usepackage{xcolor,listings}
\lstset{language={[LaTeX]TeX},
escapeinside={{(*@}{@*)}},
gobble=0,
stepnumber=1,numbersep=5pt,
numberstyle={\footnotesize\color{gray}},%firstnumber=last,
breaklines=true,
framesep=5pt,
basicstyle=\small\ttfamily,
showstringspaces=false,
keywordstyle=\ttfamily\textcolor{blue},
stringstyle=\color{orange},