
Estou usando um cls baseado memoir
no pacote listings
. Quero um capítulo de apêndice com todas as listas (lista de tabelas, lista de figuras, lista de listagens). O estilo do título dessas listas deve ser semelhante a um section
título.
Posso fazer isso para as tabelas e figuras assim:
\makeatletter
\renewcommand\@lofmaketitle{%
\section*{\listfigurename}%
\tocmark%
\@afterheading}
\makeatother
\makeatletter
\renewcommand\@lotmaketitle{%
\section*{\listtablename}%
\tocmark%
\@afterheading}
\makeatother
Então imaginei que também deveria funcionar para as listagens, mas o seguinte não tem efeito:
\makeatletter
\renewcommand\@lolmaketitle{%
\section*{\lstlistlistingname}%
\tocmark%
\@afterheading}
\makeatother
Eu uso \lstlistoflistings*
para não querer que apareça no sumário.
Como posso fazer isso?
Responder1
Isso deveria fazer isso
\documentclass[a4paper]{memoir}
\usepackage{listings}
\begin{document}
\begin{lstlisting}[caption=Hest]
a
\end{lstlisting}
\begingroup
\makeatletter
\renewcommand\@tocmaketitle{%
\section*{\contentsname}%
\markboth{\contentsname}{\contentsname}
\@afterheading}
\makeatother
% adding a star to \lstlistoflistings does not work, the inner
% \tableofcontents never sees it. Locally use \KeepFromToc
% to emulate the *
\KeepFromToc
\lstlistoflistings
\endgroup
\end{document}
Observe que a mudança não pode realmente estar no preâmbulo, pois também afeta o arquivo \tableofcontents
.
O código relevante de listings
é
\lst@UserCommand\lstlistoflistings{\bgroup
\let\contentsname\lstlistlistingname
\let\lst@temp\@starttoc \def\@starttoc##1{\lst@temp{lol}}%
\tableofcontents \egroup}
aqui podemos ver que ele é redefinido \contentsname
e qual arquivo \@starttoc
deve ser usado. \tableofcontents
geralmente é executado \@starttoc
, então eles apenas executam \tableofcontents
.