
Estoy usando un cls basado en memoir
y el paquete listings
. Quiero un capítulo de apéndice con todas las listas (lista de tablas, lista de figuras, lista de listados). El estilo del título de estas listas debe ser como un section
título.
Puedo hacer esto para las tablas y las figuras como esta:
\makeatletter
\renewcommand\@lofmaketitle{%
\section*{\listfigurename}%
\tocmark%
\@afterheading}
\makeatother
\makeatletter
\renewcommand\@lotmaketitle{%
\section*{\listtablename}%
\tocmark%
\@afterheading}
\makeatother
Entonces pensé que también debería funcionar para los listados, pero lo siguiente no tiene ningún efecto:
\makeatletter
\renewcommand\@lolmaketitle{%
\section*{\lstlistlistingname}%
\tocmark%
\@afterheading}
\makeatother
Lo uso \lstlistoflistings*
así que no me gustaría que apareciera en el TOC.
¿Cómo puedo hacer esto?
Respuesta1
Esto debería hacerlo
\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}
Tenga en cuenta que el cambio no puede estar realmente en el preámbulo ya que también afecta \tableofcontents
.
El código relevante de listings
es
\lst@UserCommand\lstlistoflistings{\bgroup
\let\contentsname\lstlistlistingname
\let\lst@temp\@starttoc \def\@starttoc##1{\lst@temp{lol}}%
\tableofcontents \egroup}
Aquí podemos ver cómo se restablece \contentsname
y qué archivo \@starttoc
se debe utilizar. \tableofcontents
generalmente se ejecuta, \@starttoc
por lo que simplemente se ejecuta \tableofcontents
.