我的一个列表名称很长。在\lstlistoflistings
目录中,我只想显示它的缩写版本。如何为我的列表指定缩写名称?
\documentclass[11pt]{book}
\usepackage[svgnames]{xcolor}
\definecolor{ocre}{RGB}{243,102,25}
\usepackage{avant}
\usepackage{mathptmx}
\usepackage{microtype}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fontspec}
\usepackage[numbered,framed]{matlab-prettifier}
\usepackage[font={color=ocre,bf},figurename=Fig.,labelfont={it}]{caption}
\usepackage{filecontents}
\begin{filecontents*}{sample.m}
% create a file for output
!touch testFile.txt
fid = fopen('testFile.text', 'w')
for i=1:10
fprintf(fid,'%6.2f \n', i);
end
\end{filecontents*}
\newfontfamily{\lstconsolas}{Consolas}
\newcommand\ph\mlplaceholder
\renewcommand{\lstlistingname}{Matlab Algorithm}
\renewcommand{\lstlistlistingname}{List of \lstlistingname s}
\begin{document}
\lstlistoflistings
\lstinputlisting[style=Matlab-editor,basicstyle=\lstconsolas,caption=Sample code from Matlab with a very very very very very loooooooooooooooong name]{sample.m}
\begin{lstlisting}[
style=Matlab-editor,
basicstyle=\lstconsolas\small,
escapechar=`,
caption={For educational purposes},
]
% example of while loop using placeholders
while x2 = 1 + 100 `\ph{condition}`
if `\ph{something-bad-happens}`
break
else
% do something useful
end
% do more things
end
\end{lstlisting}
\end{document}