在我正在处理的文档中,我有一个图表列表、一个表格列表,我刚刚添加了一个方程式列表。对于图表,我使用的是 tocloft 包。以下是我的代码片段:
\usepackage{tocloft}
\renewcommand{\cftfigleader}{}
\renewcommand{\cftfigafterpnum}{\cftparfillskip}
\renewcommand{\cfttableader}{}
\renewcommand{\cfttabafterpnum}{\cftparfillskip}
\renewcommand{\cftequleader}{}
\renewcommand{\cftequafterpnum}{\cftparfillskip}
% ============== TOC AND LISTS ===========
\renewcommand{\contentsname}{\hfill\bfseries\large Table of Contents\hfill}
\renewcommand{\cftaftertoctitle}{\hfill}
\makeatletter
\renewcommand{\@dotsep}{10000}
\makeatother
\renewcommand{\cftchapaftersnum}{.}%
\tableofcontents
\setcounter{tocdepth}{3}
\newpage
\captionsetup[table]{labelsep=none}
\renewcommand{\cftlottitlefont}{\hspace*{\fill}\large\bfseries}
\renewcommand{\cftafterlottitle}{\hspace*{\fill}}
\addcontentsline{toc}{section}{\textbf{List of Tables}}
\renewcommand{\thetable}{\arabic{table}.}
{\renewcommand{\addvspace}[1]{} \listoftables}
\newpage
\renewcommand{\cftloftitlefont}{\hspace*{\fill}\large\bfseries}
\renewcommand{\cftafterloftitle}{\hspace*{\fill}}
\addcontentsline{toc}{section}{\textbf{List of Figures}}
\renewcommand{\thefigure}{\arabic{figure}.}
{\renewcommand{\addvspace}[1]{} \listoffigures}
\newpage
\newcommand{\listofequationsname}{List of Equations}
\newlistof[section]{myequations}{equ}{\listofequationsname}
\newcommand{\myequations}[1]{%
\addcontentsline{equ}{myequations}{\protect\numberline{\theequation}#1}}
\setlength{\cftmyequationsindent}{1.5em}
\setlength{\cftmyequationsnumwidth}{2.3em}
\renewcommand{\cftequtitlefont}{\hspace*{\fill}\large\bfseries}
\renewcommand{\cftafterequtitle}{\hspace*{\fill}}
\addcontentsline{toc}{section}{\textbf{List of Equations}}
\listofmyequations
\newpage
使用此代码,我可以获取图表列表和表格列表所需的正确格式。
但是,由于 tocloft 包不处理方程式,我还没搞清楚如何对我的方程式列表做同样的事情。我需要消除点分隔符,并在列表后面立即显示页码,就像图表列表一样。
我还是 LaTeX 新手,因此提前感谢您的帮助。
这是一个工作示例,其中显示了表格列表中几个具有我需要的格式的表格。方程式列表中有两个方程式,其格式是我想要更改的。
\documentclass[12pt, floatsintext]{report}
\usepackage[utf8]{inputenc}
\usepackage[american]{babel}
\usepackage{fontspec}
\usepackage{setspace}
\usepackage{geometry}
\usepackage{appendix}
\usepackage{chngcntr}
\usepackage{xcolor}
\usepackage{trace}
\usepackage{caption}
\DeclareCaptionLabelSeparator{none}{ }
\usepackage{csquotes}
\usepackage{lmodern}
\usepackage{float}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{url}
\usepackage{graphicx}
\graphicspath{{images/}}
\usepackage{indentfirst}
\usepackage{fancyhdr}
\usepackage{tocloft}%
% set page numbers just after chapter titles
\renewcommand{\cftchapleader}{}
\renewcommand{\cftchapafterpnum}{\cftparfillskip}
% set page numbers just after section titles
\renewcommand{\cftsecleader}{}
\renewcommand{\cftsecafterpnum}{\cftparfillskip}
\renewcommand{\cftsubsecleader}{}
\renewcommand{\cftsubsecafterpnum}{\cftparfillskip}
\renewcommand{\cftfigleader}{}
\renewcommand{\cftfigafterpnum}{\cftparfillskip}
\renewcommand{\cfttableader}{}
\renewcommand{\cfttabafterpnum}{\cftparfillskip}
\renewcommand{\cftequleader}{}
\renewcommand{\cftequafterpnum}{\cftparfillskip}
\newcommand{\atoc}[1]{\addtocontents{toc}{\bigskip #1\par}}
\setmainfont{Times New Roman}
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\large\bfseries\filcenter}{\chaptertitlename\ \thechapter}{20pt}{\large}
\titlespacing*{\chapter}
{0pt}{30pt}{20pt}
\counterwithout{figure}{chapter}\counterwithout{table}{chapter}
\begin{document}
\newgeometry{left=4.0cm, right=2.54cm, top=2.54cm, bottom=2.54cm}
\setcounter{page}{1}
\pagenumbering{roman}
\pagestyle{plain}
%=======================================================
% ============== TOC AND LISTS ===========
\renewcommand{\contentsname}{\hfill\bfseries\large Table of Contents\hfill}
\renewcommand{\cftaftertoctitle}{\hfill}
\makeatletter
\renewcommand{\@dotsep}{10000}
\makeatother
\renewcommand{\cftchapaftersnum}{.}%
\tableofcontents
\setcounter{tocdepth}{3}
\newpage
\captionsetup[table]{labelsep=none}
\renewcommand{\cftlottitlefont}{\hspace*{\fill}\large\bfseries}
\renewcommand{\cftafterlottitle}{\hspace*{\fill}}
\addcontentsline{toc}{section}{\textbf{List of Tables}}
\renewcommand{\thetable}{\arabic{table}.}
{\renewcommand{\addvspace}[1]{} \listoftables}
\newpage
\renewcommand{\cftloftitlefont}{\hspace*{\fill}\large\bfseries}
\renewcommand{\cftafterloftitle}{\hspace*{\fill}}
\addcontentsline{toc}{section}{\textbf{List of Figures}}
\renewcommand{\thefigure}{\arabic{figure}.}
{\renewcommand{\addvspace}[1]{} \listoffigures}
\newpage
\newcommand{\listofequationsname}{List of Equations}
\newlistof[section]{myequations}{equ}{\listofequationsname}
\newcommand{\myequations}[1]{%
\addcontentsline{equ}{myequations}{\protect\numberline{\theequation}#1}}
\setlength{\cftmyequationsindent}{1.5em}
\setlength{\cftmyequationsnumwidth}{2.3em}
\renewcommand{\cftequtitlefont}{\hspace*{\fill}\large\bfseries}
\renewcommand{\cftafterequtitle}{\hspace*{\fill}}
\addcontentsline{toc}{section}{\textbf{List of Equations}}
\listofmyequations
\newpage
%=======================================================
% ============== CHAPTERS ===========
\newgeometry{left=4.0cm, right=2.54cm, top=2.54cm, bottom=2.54cm}
\setlength{\parindent}{36pt}
\doublespacing
\setcounter{page}{1}
\pagenumbering{arabic}
\pagestyle{fancy}
\fancyhf{}
\fancyheadoffset{0cm}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\fancyhead[R]{\thepage}
\fancypagestyle{plain}{%
\fancyhf{}%
\fancyhead[R]{\thepage}%
}
\atoc{\textbf{Chapters}}
\chapter{Introduction}
\begin{table}[H]
\begin{tabular}{l l}
\textbf{1} & First Item \\
\textbf{2} & Second Item \\
\textbf{3} & Third Item
\end{tabular}
\caption{Simple Table 1}
\label{tab:simple_list1}
\end{table}
\begin{table}[H]
\begin{tabular}{l l}
\textbf{1} & First Item \\
\textbf{2} & Second Item \\
\textbf{3} & Third Item
\end{tabular}
\caption{Simple Table 2}
\label{tab:simple_list2}
\end{table}
\begin{equation} \label{eq:bellman_eq}
\scalebox{1.5}{%
$Q(s_{t'}, a_{t}) = E[r_{t+1} + \gamma r_{t+2} +\gamma^2 r_{t+3} + ...| s_{t'}, a_{t}] $}
\end{equation}
\myequations{Bellman Equation}
\begin{equation} \label{eq:bayestheorem_eq}
\scalebox{1.2}{%
$P(M|E) = \frac{P(E|M)P(M)}{P(E)} $}
\end{equation}
\myequations{Bayes' Theorem}
\end{document}
答案1
eqn
用myequations
两行替换
\renewcommand{\cfteqnleader}{}
\renewcommand{\cfteqnafterpnum}{\cftparfillskip}
(目前我收到错误抱怨\cfteqnleader
并且\cfteqnafterpnum
未定义),然后将它们移至
\newlistof[section]{myequations}{equ}{\listofequationsname}
完整示例(有点混乱)
% !TeX TS-program = xelatex
\documentclass[12pt, floatsintext]{report}
\usepackage[utf8]{inputenc}
\usepackage[american]{babel}
\usepackage{fontspec}
\usepackage{setspace}
\usepackage{geometry}
\usepackage{appendix}
\usepackage{chngcntr}
\usepackage{xcolor}
\usepackage{trace}
\usepackage{caption}
\DeclareCaptionLabelSeparator{none}{ }
\usepackage{csquotes}
\usepackage{lmodern}
\usepackage{float}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{url}
\usepackage{graphicx}
\graphicspath{{images/}}
\usepackage{indentfirst}
\usepackage{fancyhdr}
\usepackage{tocloft}%
% set page numbers just after chapter titles
\renewcommand{\cftchapleader}{}
\renewcommand{\cftchapafterpnum}{\cftparfillskip}
% set page numbers just after section titles
\renewcommand{\cftsecleader}{}
\renewcommand{\cftsecafterpnum}{\cftparfillskip}
\renewcommand{\cftsubsecleader}{}
\renewcommand{\cftsubsecafterpnum}{\cftparfillskip}
\renewcommand{\cftfigleader}{}
\renewcommand{\cftfigafterpnum}{\cftparfillskip}
\renewcommand{\cfttableader}{}
\renewcommand{\cfttabafterpnum}{\cftparfillskip}
\newcommand{\atoc}[1]{\addtocontents{toc}{\bigskip #1\par}}
\setmainfont{Times New Roman}
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\large\bfseries\filcenter}{\chaptertitlename\ \thechapter}{20pt}{\large}
\titlespacing*{\chapter}
{0pt}{30pt}{20pt}
\counterwithout{figure}{chapter}\counterwithout{table}{chapter}
\begin{document}
\newgeometry{left=4.0cm, right=2.54cm, top=2.54cm, bottom=2.54cm}
\setcounter{page}{1}
\pagenumbering{roman}
\pagestyle{plain}
%=======================================================
% ============== TOC AND LISTS ===========
\renewcommand{\contentsname}{\hfill\bfseries\large Table of Contents\hfill}
\renewcommand{\cftaftertoctitle}{\hfill}
\makeatletter
\renewcommand{\@dotsep}{10000}
\makeatother
\renewcommand{\cftchapaftersnum}{.}%
\tableofcontents
\setcounter{tocdepth}{3}
\newpage
\captionsetup[table]{labelsep=none}
\renewcommand{\cftlottitlefont}{\hspace*{\fill}\large\bfseries}
\renewcommand{\cftafterlottitle}{\hspace*{\fill}}
\addcontentsline{toc}{section}{\textbf{List of Tables}}
\renewcommand{\thetable}{\arabic{table}.}
{\renewcommand{\addvspace}[1]{} \listoftables}
\newpage
\renewcommand{\cftloftitlefont}{\hspace*{\fill}\large\bfseries}
\renewcommand{\cftafterloftitle}{\hspace*{\fill}}
\addcontentsline{toc}{section}{\textbf{List of Figures}}
\renewcommand{\thefigure}{\arabic{figure}.}
{\renewcommand{\addvspace}[1]{} \listoffigures}
\newpage
\newcommand{\listofequationsname}{List of Equations}
\newlistof[section]{myequations}{equ}{\listofequationsname}
\renewcommand{\cftmyequationsleader}{}
\renewcommand{\cftmyequationsafterpnum}{\cftparfillskip}
\newcommand{\myequations}[1]{%
\addcontentsline{equ}{myequations}{\protect\numberline{\theequation}#1}}
\setlength{\cftmyequationsindent}{1.5em}
\setlength{\cftmyequationsnumwidth}{2.3em}
\renewcommand{\cftequtitlefont}{\hspace*{\fill}\large\bfseries}
\renewcommand{\cftafterequtitle}{\hspace*{\fill}}
\addcontentsline{toc}{section}{\textbf{List of Equations}}
\listofmyequations
\newpage
%=======================================================
% ============== CHAPTERS ===========
\newgeometry{left=4.0cm, right=2.54cm, top=2.54cm, bottom=2.54cm}
\setlength{\parindent}{36pt}
\doublespacing
\setcounter{page}{1}
\pagenumbering{arabic}
\pagestyle{fancy}
\fancyhf{}
\fancyheadoffset{0cm}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\fancyhead[R]{\thepage}
\fancypagestyle{plain}{%
\fancyhf{}%
\fancyhead[R]{\thepage}%
}
\atoc{\textbf{Chapters}}
\chapter{Introduction}
\begin{table}[H]
\begin{tabular}{l l}
\textbf{1} & First Item \\
\textbf{2} & Second Item \\
\textbf{3} & Third Item
\end{tabular}
\caption{Simple Table 1}
\label{tab:simple_list1}
\end{table}
\begin{table}[H]
\begin{tabular}{l l}
\textbf{1} & First Item \\
\textbf{2} & Second Item \\
\textbf{3} & Third Item
\end{tabular}
\caption{Simple Table 2}
\label{tab:simple_list2}
\end{table}
\begin{equation} \label{eq:bellman_eq}
\scalebox{1.5}{%
$Q(s_{t'}, a_{t}) = E[r_{t+1} + \gamma r_{t+2} +\gamma^2 r_{t+3} + ...| s_{t'}, a_{t}] $}
\end{equation}
\myequations{Bellman Equation}
\begin{equation} \label{eq:bayestheorem_eq}
\scalebox{1.2}{%
$P(M|E) = \frac{P(E|M)P(M)}{P(E)} $}
\end{equation}
\myequations{Bayes' Theorem}
\end{document}