![リストページ番号のカスタムリストが機能しない](https://rvso.com/image/309863/%E3%83%AA%E3%82%B9%E3%83%88%E3%83%9A%E3%83%BC%E3%82%B8%E7%95%AA%E5%8F%B7%E3%81%AE%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%A0%E3%83%AA%E3%82%B9%E3%83%88%E3%81%8C%E6%A9%9F%E8%83%BD%E3%81%97%E3%81%AA%E3%81%84.png)
私はこの特定の LaTeX テンプレートをしばらく使用しており、必要に応じて追加や変更を続けています。最近、TOC、LOF、LOT、および LOL の先頭のドットを削除するために再フォーマットを試みましたが、コマンドを更新することですべて削除できましたが\cftdot
、LOL ではうまくいかなかったようです。
\titlecontents
パッケージのコマンドを使用してtitletoc
LOL の設定を変更しましたが、これによりページ番号がリストの残りの部分と揃わなくなりました。 と を試して\hfill
この\titlerule*[0.0em]{.}
問題\contentspage
を解決しましたが、どちらも機能しませんでした。
現在動作している例は でデモされています\hfill
。
\documentclass[12pt]{article}
\usepackage{geometry}
\geometry{letterpaper}
\geometry{margin = 1.0in}
\usepackage[parfill]{parskip}
\usepackage{setspace}
\singlespacing
\usepackage[utf8x]{inputenc}
\usepackage{microtype}
\usepackage{listings}
\usepackage{graphicx}
\usepackage[justification = centering]{caption}
\usepackage[section]{placeins}
\usepackage{float}
\usepackage[nottoc,notlof,notlot]{tocbibind}
\usepackage[titles]{tocloft}
\usepackage{titletoc}
\renewcommand{\cftsecfont}{\rmfamily\mdseries\upshape}
\renewcommand{\cftsecpagefont}{\rmfamily\mdseries\upshape}
\renewcommand{\cftdot}{}
\renewcommand\lstlistlistingname{List of Scripts}
\renewcommand\lstlistingname{Script}
\contentsuse{lstlisting}{lol}
\titlecontents{lstlisting}[1.5em]
{\hspace{2.3em}}
{\contentslabel{2.3em}}
{\hspace*{-2.3em}}
{\hfill\contentspage}
\usepackage{hyperref}
\pdfoutput=1
\hypersetup{
unicode=false,
pdftoolbar=true,
pdfmenubar=true,
pdffitwindow=true,
pdfstartview={FitH},
pdftitle={Title},
pdfauthor={Author},
pdfsubject={Subject},
pdfcreator={Producer},
pdfproducer={Producer},
pdfdisplaydoctitle=true,
pdfnewwindow=true,
colorlinks=true,
linkcolor=black,
citecolor=black,
filecolor=black,
urlcolor=black
}
\begin{document}
\tableofcontents
\listoffigures
\listoftables
\lstlistoflistings
\section{Here is A Section}
\begin{figure}[H]
\centering
\includegraphics[width = 2cm]{boats}
\caption{A boat}
\end{figure}
\begin{table} [H]
\begin{center}
\begin{tabular}{ c | c }
Title 1 & Title 2 \\ \hline
Stuff & More stuff
\end{tabular}
\caption{A Table}
\end{center}
\end{table}
\begin{lstlisting}[language = Matlab, basicstyle = \scriptsize, numberstyle = \scriptsize, caption = A Listing]
%%
clear;clc;close all;format compact;
%%
x = 5;
y = 6;
x + y = z;
disp(z);
\end{lstlisting}
\end{document}
以下の例でわかるように、リストのページ番号は、私が理解できない何らかの理由でインデントされています。簡単なことだと思いますが、まだ見つけられていません。
なお、私はこれよりもはるかに多くのパッケージと変更を使用していますが、これらは適切にコンパイルされる最も基本的なものです。
答え1
tocloft
は、標準のToC
、コマンド、ファイル、および を使用して定義されたものにのみフックします。LoF
LoT
\newlistof
これらすべてはLoL
、 のようなマクロの従来の設定を使用する ではカバーされていません\l@...
。
ではlistings.sty
\def\l@lstlisting#1#2{\@dottedtocline{1}{1.5em}{2.3em}{#1}{#2}}
これは、コンテンツ リストの行設定に関連するマクロです。次のレベルには、コンテンツ ラインの 2 つのドット間の区切りスペースとして\@dottedtocline
使用する LaTeX カーネル マクロがあります。デフォルト値は です。この数値を 5000 (非常に大きい値) に増やすと、ドットはおそらくここでは見えなくなります。\@dotsep
4.5
グローバルに変更したくなかったので\@dotsep
、コマンドにパッチを適用しました(使用\l@lstlisting
後に設定を削除するグループを使用)\l@lstlisting
\makeatletter % Patching to prevent interference
\xpatchcmd{\l@lstlisting}{\@dottedtocline{1}{1.5em}{2.3em}{#1}{#2}}{%
\begingroup\renewcommand{\@dotsep}{5000}\@dottedtocline{1}{1.5em}{2.3em}{#1}{#2}\endgroup}{%
}{}
\makeatother
これがコードです(titletoc
関連する部分はコメントアウトされています)
\documentclass[12pt]{article}
\usepackage{geometry}
\geometry{letterpaper}
\geometry{margin = 1.0in}
\usepackage[parfill]{parskip}
\usepackage{setspace}
\singlespacing
\usepackage[utf8x]{inputenc}
\usepackage{microtype}
\usepackage[demo]{graphicx}
\usepackage[justification = centering]{caption}
\usepackage[section]{placeins}
\usepackage{float}
\usepackage[nottoc,notlof,notlot]{tocbibind}
\usepackage{listings}
\usepackage[titles]{tocloft}
\usepackage{xpatch}
%\usepackage{titletoc}
\renewcommand{\cftsecfont}{\rmfamily\mdseries\upshape}
\renewcommand{\cftsecpagefont}{\rmfamily\mdseries\upshape}
\renewcommand{\cftdotsep}{\cftnodots}
\renewcommand\lstlistlistingname{List of Scripts}
\renewcommand\lstlistingname{Script}
\makeatletter % Patching to prevent interference
\xpatchcmd{\l@lstlisting}{\@dottedtocline{1}{1.5em}{2.3em}{#1}{#2}}{%
\begingroup\renewcommand{\@dotsep}{5000}\@dottedtocline{1}{1.5em}{2.3em}{#1}{#2}\endgroup}{%
}{}
\makeatother
%\contentsuse{lstlisting}{lol}
%\titlecontents{lstlisting}[1.5em]
% {\hspace{2.3em}}
% {\contentslabel{2.3em}}
% {\hspace*{-2.3em}}
% {\hfill\contentspage}
\usepackage{hyperref}
\pdfoutput=1
\hypersetup{
unicode=false,
pdftoolbar=true,
pdfmenubar=true,
pdffitwindow=true,
pdfstartview={FitH},
pdftitle={Title},
pdfauthor={Author},
pdfsubject={Subject},
pdfcreator={Producer},
pdfproducer={Producer},
pdfdisplaydoctitle=true,
pdfnewwindow=true,
colorlinks=true,
linkcolor=black,
citecolor=black,
filecolor=black,
urlcolor=black
}
\begin{document}
\tableofcontents
\listoffigures
\listoftables
\lstlistoflistings
\section{Here is A Section}
\begin{figure}[H]
\centering
\includegraphics[width = 2cm]{boats}
\caption{A boat}
\end{figure}
\begin{table} [H]
\begin{center}
\begin{tabular}{ c | c }
Title 1 & Title 2 \\ \hline
Stuff & More stuff
\end{tabular}
\caption{A Table}
\end{center}
\end{table}
\begin{lstlisting}[language = Matlab, basicstyle = \scriptsize, numberstyle = \scriptsize, caption = A Listing]
%%
clear;clc;close all;format compact;
%%
x = 5;
y = 6;
x + y = z;
disp(z);
\end{lstlisting}
\end{document}