
我如何產生原始程式碼列表,就像圖形列表一樣?
這是程式碼來源清單的範例:
\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 標題」部分。