13

This question already has an answer here:

In tex environment, when I try to use the verbatim function using verbatim packages, sometimes the longer text in the line tend to be cut off. How can I resize the text to fit into the line or automatically extend the text to the next line so as to retain all the text. For example I have the following text:

    \begin{verbatim}
        C **  RAINCVT   =CONVERTS RAIN TO UNITS OF M/SEC , inch/day=0.0254m/86400s=2.94E-7m/s, inch/h=7.05556E-6m/s
C **  EVAPCVT   =CONVERTS EVAP TO UNITS OF M/SEC, IF EVAPCVT<0 EVAP IS INTERNALLY COMPUTED
C **  SOLRCVT   =CONVERTS SOLAR SW RADIATION TO JOULES/S/SQ METER (Watts/m^2)
    \end{verbatim}

In my output the first line doesn't show all the text. I would also appreciate if someone could tell how to limit the floating verbatim ? In tables using the label [h] at the end would fix the position of the table which doesn't seem to work on verbatim.

marked as duplicate by user13907, user2478, Mensch, Andrew, Mico Apr 5 '16 at 14:21

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

18

The standard verbatim environment is very basic. To have automatic line breaking, use the listings package and its breaklines=true option:

\documentclass[11pt]{article}
\usepackage{listings}
\lstset{
basicstyle=\small\ttfamily,
columns=flexible,
breaklines=true
}

\begin{document}

With the standard \texttt{verbatim} environment:
\begin{verbatim}
        C **  RAINCVT   =CONVERTS RAIN TO UNITS OF M/SEC , inch/day=0.0254m/86400s=2.94E-7m/s, inch/h=7.05556E-6m/s
C **  EVAPCVT   =CONVERTS EVAP TO UNITS OF M/SEC, IF EVAPCVT<0 EVAP IS INTERNALLY COMPUTED
C **  SOLRCVT   =CONVERTS SOLAR SW RADIATION TO JOULES/S/SQ METER (Watts/m^2)
    \end{verbatim}

With the \texttt{lstlisting} environment and \texttt{breaklines=true}:
\begin{lstlisting}
        C **  RAINCVT   =CONVERTS RAIN TO UNITS OF M/SEC , inch/day=0.0254m/86400s=2.94E-7m/s, inch/h=7.05556E-6m/s
C **  EVAPCVT   =CONVERTS EVAP TO UNITS OF M/SEC, IF EVAPCVT<0 EVAP IS INTERNALLY COMPUTED
C **  SOLRCVT   =CONVERTS SOLAR SW RADIATION TO JOULES/S/SQ METER (Watts/m^2)
    \end{lstlisting}

\end{document}

enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.