
estou usando othesul
aula. Gostaria de adicionar minhas listagens ao índice.
Encontrei uma maneira de fazer isso usando o \addcontentsline{toc}{spsection}{Listings}
comando:
\tableofcontents
\listoffigures
\listoftables
\lstlistoflistings
\addcontentsline{toc}{spsection}{Listings}
Mas o problema é que o marcador de PDF correspondente que já foi adicionado é adicionado uma segunda vez devido ao uso deste comando.
Então, talvez eu precise modificar o thesul.cls
arquivo.
Editar 1: Desculpe, esqueci o tulhypref
pacote, então não há marcadores com este main.tex
arquivo. Aqui está o main.tex
arquivo correto:
\documentclass{thesul}
\usepackage{tulhypref} % for bookmarks
\usepackage{listings} % for \lstlistoflistings
\begin{document}
\tableofcontents
\listoffigures
\listoftables
\lstlistoflistings
\addcontentsline{toc}{spsection}{Listings}
\chapter{My first chapter}
Hello, this is my first chapter.
\section{My first section}
Hello, this is my first section.
\begin{lstlisting}
echo "hello world";
\end{lstlisting}
\end{document}
Edição 2: Aqui está o resultado:
Mas encontrei uma solução alternativa.
Quando uso o \lstlistoflistings
comando, preciso fazer:
\hypersetup{bookmarksdepth=-1}
\lstlistoflistings
\hypersetup{bookmarksdepth}
Aqui está o código completo:
\documentclass{thesul}
\usepackage{tulhypref} % for bookmarks
\usepackage{listings} % for \lstlistoflistings
\begin{document}
\tableofcontents
\listoffigures
\listoftables
\hypersetup{bookmarksdepth=-1} % add this line (to disable bookmarks)
\lstlistoflistings
\hypersetup{bookmarksdepth} % add this line (to enable bookmarks)
\addcontentsline{toc}{spsection}{Listings}
\chapter{My first chapter}
Hello, this is my first chapter.
\section{My first section}
Hello, this is my first section.
\begin{lstlisting}
echo "hello world";
\end{lstlisting}
\end{document}
Responder1
Em vez de usar listings
um mecanismo integrado, prefiro definir um novo ambiente flutuante e usá-lo junto com lstlisting
(assim como você usa um table
float junto com um tabular
ambiente):
O seguinte funciona sem problemas e fornece os resultados esperados:
\documentclass{thesul}
\usepackage{tulhypref} % for bookmarks
\usepackage{listings} % for \lstlistoflistings
\usepackage{newfloat}
\DeclareFloatingEnvironment[
fileext = lol ,
listname = {List Of Listings} ,
name = Listing
]{listing}
\begin{document}
\tableofcontents
\listoffigures
\listoftables
\listoflistings
\chapter{My first chapter}
Hello, this is my first chapter.
\section{My first section}
Hello, this is my first section.
\begin{listing}
\begin{lstlisting}
echo "hello world";
\end{lstlisting}
\caption{My listing's caption.}
\end{listing}
\end{document}