我正在用 LATEX un=sing sharelatex.com 写一个算法。我写了一条很长的评论,它从一个点被截取了。
我曾写过这样的文章:
%This is a LaTeX template for homework assignments
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{listings}
\begin{document}
\begin{lstlisting}
Function(A[1...n],x){
...............
count=0;
H(A[1...n],n);
if (a==0){
while (j<=n and A[j]<=0){
................
}
/* If there is at least one element that is equal to zero and at least one non-zero element then there are two elements with the desired property. In any other case the variable found is not changed. */
if (count!=0 and count!=n) found=1;
}
.............
\end{lstlisting}
\end{document}
它看起来像这样:
我能做什么?
答案1
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{listings}
\begin{document}
\begin{lstlisting}[breaklines=true]
Function(A[1...n],x){
...............
count=0;
H(A[1...n],n);
if (a==0){
while (j<=n and A[j]<=0){
................
}
/* If there is at least one element that is equal to zero and at least one non-zero element then there are two elements with the desired property. In any other case the variable found is not changed. */
if (count!=0 and count!=n) found=1;
}
.............
\end{lstlisting}
\end{document}