我使用\begin{verbatim}
并\end{verbatim}
已在其中附上 Fortran 代码。(我不使用列表是有原因的)。
然而,Verbatim 却超越了界限。
我该如何解决?
我的包裹清单是:
\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}
答案1
您正在加载列表包,因此使用key breaklines=true
和\begin{lstlisting}...\end{lstlisting}
。
\documentclass{article}
\usepackage{xcolor,listings}
\lstloadlanguages{[LaTeX]TeX, [primitive]TeX,fortran}
\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},
commentstyle=\color{black},
rulecolor=\color{gray!10},
breakatwhitespace=true,
showspaces=false, % shows spacing symbol
backgroundcolor=\color{gray!15}}
\begin{document}
\begin{lstlisting}
a very long and totruous path which you can check to see if it breaks and where at the end of the line
\end{lstlisting}
\end{document}