na minha tese tenho alguns scripts R no final, como um apêndice. Dentro do próprio apêndice eu quero o arquivo \lstlistoflistings
.
Isso formata a lista como um capítulo (o mesmo que para o toc).
Como posso formatá-lo como seção? Só quero evitar a quebra de página após o título do capítulo e ter a lista logo depois, com fonte menor.
Aqui está um exemplo mínimo de trabalho
\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}
Obrigado!
Responder1
Você poderia carregar tocbasic
e scrhack
. Então você pode 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}
Alterei a ordem \chapter*
e \addcontentsline
para obter o número de página correto no ToC.
Responder2
\lstlistoflistings
(que nome fácil de lembrar ;-)) usa \tableofcontents
internamente na verdade e redefine \@starttoc
um pouco para aplicar, mas ainda tem o \chapter*
título de \tableofcontents
.
No meu ponto de vista, é mais fácil aplicar uma redefinição de \lstlistoflistings
tal forma que tenha a mesma aparência 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}