清单下方签名

清单下方签名

我怎样才能将自动签名放在代码清单下方。现在我将代码清单放在如下位置:

\begin{lstlisting}
MY CODE
\end{lstlisting}

列表设置:

    \usepackage{color}
\definecolor{bluekeywords}{rgb}{0.13,0.13,1}
\definecolor{greencomments}{rgb}{0,0.5,0}
\definecolor{redstrings}{rgb}{0.9,0,0}

\usepackage{listings}
\lstset{language=[Sharp]C,
  showspaces=false,
  showtabs=false,
  breaklines=true,
  numbers=left,
  frame=single,
  showstringspaces=false,
  breakatwhitespace=true,
  escapeinside={(*@}{@*)},
  commentstyle=\color{greencomments},
  keywordstyle=\color{bluekeywords},
  stringstyle=\color{redstrings},
  basicstyle=\ttfamily
}

答案1

您可以使用caption键来获取标题;使用captionpos=b以使标题出现在列表下方(默认位置在上方)。该命令为\lstlistoflistings您提供了已声明标题的所有列表的列表。

\documentclass{article}
\usepackage{listings}
\usepackage{xcolor}

\definecolor{bluekeywords}{rgb}{0.13,0.13,1}
\definecolor{greencomments}{rgb}{0,0.5,0}
\definecolor{redstrings}{rgb}{0.9,0,0}

\usepackage{listings}
\lstset{language=[Sharp]C,
  showspaces=false,
  showtabs=false,
  breaklines=true,
  numbers=left,
  frame=single,
  showstringspaces=false,
  breakatwhitespace=true,
  escapeinside={(*@}{@*)},
  commentstyle=\color{greencomments},
  keywordstyle=\color{bluekeywords},
  stringstyle=\color{redstrings},
  basicstyle=\ttfamily,
  captionpos=b
}

\begin{document}

\lstlistoflistings

\begin{lstlisting}[caption={this is some description of the first listing}]
MY CODE
\end{lstlisting}

\begin{lstlisting}[caption={this is some description of the second listing}]
MY CODE
\end{lstlisting}

\begin{lstlisting}[caption={this is some description of the third listing}]
MY CODE
\end{lstlisting}

\end{document}

在此处输入图片描述

相关内容