En mi tesis tengo algunos scripts R al final, como Apéndice. Dentro del apéndice quiero el archivo \lstlistoflistings
.
Esto formatea la lista como un capítulo (igual que para el toc).
¿Cómo puedo formatearlo como sección? Solo quiero evitar el salto de página después del título del capítulo y tener la lista justo después, con una fuente más pequeña.
Aquí hay un ejemplo de trabajo mínimo.
\documentclass{report}
\usepackage{listings}
\lstset{language=R}
\renewcommand{\lstlistlistingname}{List of R scripts}
\begin{document}
\tableofcontents
\chapter{the first chapter}
\section{section1}
some text
\chapter{the second chapter}
\addcontentsline{toc}{chapter}{Appendix A}
\chapter*{Appendix A}
\lstlistoflistings
\newpage
\begin{lstlisting}[caption=A script]
some code
\end{lstlisting}
\begin{lstlisting}[caption=Another script]
some more code
\end{lstlisting}
\end{document}
¡Gracias!
Respuesta1
Podrías cargar tocbasic
y scrhack
. Entonces puedes usar \setuptoc{lol}{leveldown}
:
\documentclass{report}
\usepackage{scrhack}
\usepackage{tocbasic}
\setuptoc{lol}{leveldown}
\usepackage{listings}
\lstset{language=R}
\renewcommand{\lstlistlistingname}{List of R scripts}
\begin{document}
\tableofcontents
\chapter{the first chapter}
\section{section1}
some text
\chapter{the second chapter}
\chapter*{Appendix A}
\addcontentsline{toc}{chapter}{Appendix A}
\lstlistoflistings
\newpage
\begin{lstlisting}[caption=A script]
some code
\end{lstlisting}
\begin{lstlisting}[caption=Another script]
some more code
\end{lstlisting}
\end{document}
Cambié el orden de \chapter*
y \addcontentsline
para obtener el número de página correcto en ToC.
Respuesta2
\lstlistoflistings
(qué nombre tan fácil de recordar ;-)) \tableofcontents
en realidad lo usa internamente y lo redefine \@starttoc
ligeramente para aplicarlo, pero todavía tiene el \chapter*
título de \tableofcontents
.
Desde mi punto de vista, es más fácil aplicar una redefinición de \lstlistoflistings
tal que tenga la misma apariencia que \tableofcontents
.
\documentclass{report}
\usepackage{listings}
\lstset{language=R}
\renewcommand{\lstlistlistingname}{List of R scripts}
\makeatletter
\renewcommand{\lstlistoflistings}{%
\begingroup
\clearpage
\section*{\lstlistlistingname% Taken from `article.cls`....
\@mkboth{%
\MakeUppercase\lstlistlistingname}{\MakeUppercase
\lstlistlistingname}
}%
\@starttoc{lol}
\endgroup
}
\makeatother
\begin{document}
\tableofcontents
\chapter{the first chapter}
\section{section1}
some text
\chapter{the second chapter}
\addcontentsline{toc}{chapter}{Appendix A}
\chapter*{Appendix A}
\lstlistoflistings
\newpage
\begin{lstlisting}[caption=A script]
some code
\end{lstlisting}
\begin{lstlisting}[caption=Another script]
some more code
\end{lstlisting}
\end{document}