
estoy usando elthesul
clase. Me gustaría agregar mis listados a la tabla de contenido.
Encontré una manera de hacerlo usando el \addcontentsline{toc}{spsection}{Listings}
comando:
\tableofcontents
\listoffigures
\listoftables
\lstlistoflistings
\addcontentsline{toc}{spsection}{Listings}
Pero el problema es que el marcador PDF correspondiente que ya se agregó se agrega por segunda vez debido al uso de este comando.
Entonces, tal vez necesite modificar el thesul.cls
archivo.
Edición 1: Lo siento, olvidé el tulhypref
paquete, por lo que no hay marcadores con este main.tex
archivo. Aquí está el main.tex
archivo correcto:
\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}
Edición 2: Aquí está el resultado:
Pero encontré una solución.
Cuando uso el \lstlistoflistings
comando, necesito hacer:
\hypersetup{bookmarksdepth=-1}
\lstlistoflistings
\hypersetup{bookmarksdepth}
Aquí está el 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}
Respuesta1
En lugar de usar listings
un mecanismo incorporado, prefiero definir un nuevo entorno flotante y usarlo junto con lstlisting
(tal como se usa un table
flotante junto con un tabular
entorno):
Lo siguiente funciona sin problemas y da los 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}