![自动逐字换行文本](https://linux22.com/image/271184/%E8%87%AA%E5%8A%A8%E9%80%90%E5%AD%97%E6%8D%A2%E8%A1%8C%E6%96%87%E6%9C%AC.png)
在 tex 环境中,当我尝试使用 verbatim 包中的 verbatim 函数时,有时行中较长的文本会被截断。我该如何调整文本大小以适合行或自动将文本延伸到下一行以保留所有文本。例如,我有以下文本:
\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}
在我的输出中,第一行没有显示所有文本。如果有人能告诉我如何限制浮动逐字,我将不胜感激?在表格中使用[h]
末尾的标签可以固定表格的位置,但对逐字似乎不起作用。
答案1
标准verbatim
环境非常基础。要实现自动换行,请使用listings
包及其breaklines=true
选项:
\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}