リストページ番号のカスタムリストが機能しない

リストページ番号のカスタムリストが機能しない

私はこの特定の LaTeX テンプレートをしばらく使用しており、必要に応じて追加や変更を続けています。最近、TOC、LOF、LOT、および LOL の先頭のドットを削除するために再フォーマットを試みましたが、コマンドを更新することですべて削除できましたが\cftdot、LOL ではうまくいかなかったようです。

\titlecontentsパッケージのコマンドを使用してtitletocLOL の設定を変更しましたが、これによりページ番号がリストの残りの部分と揃わなくなりました。 と を試して\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}

以下の例でわかるように、リストのページ番号は、私が理解できない何らかの理由でインデントされています。簡単なことだと思いますが、まだ見つけられていません。
LaTeX出力の例

なお、私はこれよりもはるかに多くのパッケージと変更を使用していますが、これらは適切にコンパイルされる最も基本的なものです。

答え1

tocloftは、標準のToC、コマンド、ファイル、および を使用して定義されたものにのみフックします。LoFLoT\newlistof

これらすべてはLoL、 のようなマクロの従来の設定を使用する ではカバーされていません\l@...

ではlistings.sty

\def\l@lstlisting#1#2{\@dottedtocline{1}{1.5em}{2.3em}{#1}{#2}}

これは、コンテンツ リストの行設定に関連するマクロです。次のレベルには、コンテンツ ラインの 2 つのドット間の区切りスペースとして\@dottedtocline使用する LaTeX カーネル マクロがあります。デフォルト値は です。この数値を 5000 (非常に大きい値) に増やすと、ドットはおそらくここでは見えなくなります。\@dotsep4.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}

ここに画像の説明を入力してください

関連情報