如何修改目录listings条目的indent及numwidth

2019-12-31 14:42发布

可以用这样的命令修改figure目录中条目的indent为0em, numwidth的值为2.55em: `\cftsetindents{figure}{0em}{2.55em}` 为什么用同样的方...

可以用这样的命令修改figure目录中条目的indent为0em, numwidth的值为2.55em: `\cftsetindents{figure}{0em}{2.55em}` 为什么用同样的方法改listing时就不行呢。 `\cftsetindents{lstlisting}{0em}{2.55em}` 那么应如何修改 目录中listings中条目的indent及numwidth呢?谢谢。 源码详见mwe_lstlisting.tex ```tex %mwe_lstlisting.tex \documentclass{memoir} \usepackage{lipsum} \usepackage{mwe} \usepackage{listings} \begin{document} \frontmatter %\tableofcontents \cftsetindents{table}{0em}{2.55em} \listoftables \cftsetindents{figure}{0em}{2.55em} \listoffigures \cftsetindents{lstlisting}{0em}{2.55em} \renewcommand{\lstlistlistingname}{List of Listings} \lstlistoflistings \addcontentsline{toc}{chapter}{List of Listings} \clearpage \mainmatter \chapter{test1} \lipsum[1-4] \begin{table} \centering \caption{test1} \begin{tabular}{l} askdfakjs;dkjfalksed \end{tabular} \end{table} \begin{figure} \centering \includegraphics[width=0.3\linewidth]{example-image-a} \caption{test} \end{figure} \begin{lstlisting}[caption=test1] ta;lskjdfajsejfoqijwepojiqpowijeojrqowjeo asdfqw;efqowie qwefoqjwero \end{lstlisting} \begin{lstlisting}[caption=test2] ta;lskjdfajsejfoqijwepojiqpowijeojrqowjeo asdfqw;efqowie qwefoqjwero \end{lstlisting} \end{document} ```
1条回答
先给出一个代码 ```tex \documentclass{memoir} \usepackage{lipsum} \usepackage{mwe} \usepackage{listings} \renewcommand{\lstlistlistingname}{List of Listings} \begingroup \makeatletter \let\newcounter\@gobble \let\setcounter\@gobbletwo \globaldefs\@ne \let\c@loldepth\@ne \newlistof{listings}{lol}{\lstlistlistingname} \newlistentry{lstlisting}{lol}{0} \endgroup \begin{document} \frontmatter \tableofcontents \listoftables \listoffigures \listings \mainmatter \chapter{the first chapter} \lipsum \begin{table} \centering \caption{caption of table} \begin{tabular}{l} this is a tabular. \end{tabular} \end{table} \begin{figure} \centering \includegraphics[width=\linewidth]{example-image-a} \caption{caption of figure} \end{figure} \begin{lstlisting}[caption={caption of listing}] #include int main() { printf("hello world"); return 1; } \end{lstlisting} \begin{lstlisting}[caption={caption of another listing}] import numpy as np a = np.linspace(10) print(a) \end{lstlisting} \end{document} ``` 更多的讨论参考 [https://github.com/CTeX-org/forum/issues/84](https://github.com/CTeX-org/forum/issues/84)

一周热门 更多>

相关问答