
私はthesul
クラス。目次に自分のリストを追加したいと思います。
次のコマンドを使用してそれを実行する方法を見つけました\addcontentsline{toc}{spsection}{Listings}
:
\tableofcontents
\listoffigures
\listoftables
\lstlistoflistings
\addcontentsline{toc}{spsection}{Listings}
しかし、問題は、このコマンドの使用により、すでに追加されている対応する PDF ブックマークが 2 回追加されることです。
したがって、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}
しかし、回避策を見つけました。
コマンドを使用する場合は\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
組み込みのメカニズムを使用する代わりに、新しいフローティング環境を定義して、それを一緒に使用します (環境と一緒に floatlstlisting
を使用するのと同じように)。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}