
Я используюthesul
класс. Я хотел бы добавить свои объявления в оглавление.
Я нашел способ сделать это с помощью \addcontentsline{toc}{spsection}{Listings}
команды:
\tableofcontents
\listoffigures
\listoftables
\lstlistoflistings
\addcontentsline{toc}{spsection}{Listings}
Но проблема в том, что соответствующая закладка PDF, которая уже была добавлена, добавляется второй раз из-за использования этой команды.
Так что, возможно, мне нужно изменить thesul.cls
файл.
Редактировать 1: Извините, я забыл пакет tulhypref
, поэтому закладок с этим файлом нет main.tex
. Вот правильный main.tex
файл:
\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}
Редактирование 2: Вот результат:
Но я нашел обходной путь.
При использовании \lstlistoflistings
команды мне необходимо сделать:
\hypersetup{bookmarksdepth=-1}
\lstlistoflistings
\hypersetup{bookmarksdepth}
Вот полный код:
\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}
решение1
Вместо использования listings
встроенного механизма я бы лучше определил новую плавающую среду и использовал ее вместе с lstlisting
(точно так же, как вы используете table
плавающий объект вместе со tabular
средой):
Следующий процесс проходит гладко и дает ожидаемые результаты:
\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}