我如何才能生成像图形列表一样的源代码列表?
下面是代码源清单的示例:
\lstset{
numbers=left,
stepnumber=1,
numbersep=5pt,
numberstyle=\small\color{black},
basicstyle=\ttfamily\small,
keywordstyle=\color{black},
commentstyle=\color{black},
stringstyle=\color{black},
frame=single,
backgroundcolor=\color{lightgray},
caption=Code coté serveur avec Express}
\begin{lstlisting}[firstnumber=1, framerule=0pt] % Start your code-block
%Code ...
\end{lstlisting}
答案1
\lstlistoflistings
打印列表列表:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{xcolor}
\usepackage{listings}
\usepackage[french]{babel}
\addto\captionsfrench{%
\renewcommand*{\lstlistlistingname}{Liste des sources}%
\renewcommand*{\lstlistingname}{Source}%
}
\begin{document}
\lstlistoflistings
\lstset{
numbers=left,
stepnumber=1,
numbersep=5pt,
numberstyle=\small\color{black},
basicstyle=\ttfamily\small,
keywordstyle=\color{black},
commentstyle=\color{black},
stringstyle=\color{black},
frame=single,
backgroundcolor=\color{lightgray},
caption=Code coté serveur avec Express}
\begin{lstlisting}[firstnumber=1, framerule=0pt] % Start your code-block
%Code ...
\end{lstlisting}
\end{document}
进一步阅读:包装文件listings
, 第“4.9 标题”一节。