如何使用 tocloft 将新列表的标题置于中央?

如何使用 tocloft 将新列表的标题置于中央?

我想使用这个答案中的命令创建一个方程列表问题

我现在想将“方程式列表”标题居中。我尝试调整用于将目录、图片列表和表格列表居中的命令:

\renewcommand{\SOMETHING}{\hspace*{\fill}\Huge\bfseries}
\renewcommand{\SOMETHING}{\hspace*{\fill}}

但它并没有按预期工作。我不知道 SOMETHING 是什么。下面是一个工作示例,其中包含我尝试过的一些操作:

\documentclass[12pt]{report}
\usepackage{tocloft}
\usepackage[a4paper,width=150mm,top=25mm,bottom=25mm,bindingoffset=6mm]{geometry}

%%gmedina solution
\newcommand{\listequationsname}{List of Equations}
\newlistof{myequations}{equ}{\listequationsname}
\newcommand{\myequations}[1]{%
\addcontentsline{equ}{myequations}{\protect\numberline{\theequation}#1}\par}
\setlength{\cftmyequationsnumwidth}{2.5em}% Width of equation number in List of Equations

% editing ToC, LoF, LoT does not affect the new list
\renewcommand{\cfttoctitlefont}{\hspace*{\fill}\Huge\bfseries}
\renewcommand{\cftaftertoctitle}{\hspace*{\fill}}
\renewcommand{\cftlottitlefont}{\hspace*{\fill}\Huge\bfseries}
\renewcommand{\cftafterlottitle}{\hspace*{\fill}}
\renewcommand{\cftloftitlefont}{\hspace*{\fill}\Huge\bfseries}
\renewcommand{\cftafterloftitle}{\hspace*{\fill}}

% empties the list
%\renewcommand{\myequations}{\hspace*{\fill}\Huge\bfseries}
%\renewcommand{\myequations}{\hspace*{\fill}}

% undefined command error
%\renewcommand{\listequations}{\hspace*{\fill}\Huge\bfseries}
%\renewcommand{\listequations}{\hspace*{\fill}}

% undo the numbering
%\renewcommand{\theequation}{\hspace*{\fill}\Huge\bfseries}
%\renewcommand{\theequation}{\hspace*{\fill}}

% empties the list
%\renewcommand{\listofmyequations}{\hspace*{\fill}\Huge\bfseries}
%\renewcommand{\listofmyequations}{\hspace*{\fill}}

% The title disappears
%\renewcommand{\listequationsname}{\hspace*{\fill}\Huge\bfseries}
%\renewcommand{\listequationsname}{\hspace*{\fill}}

% undefined command error
%\renewcommand{\cftmyequationstitlefont}{\hspace*{\fill}\Huge\bfseries}
%\renewcommand{\cftaftermyequationstitle}{\hspace*{\fill}}

\begin{document}

\listofmyequations

\chapter{sums}

\begin{equation}
    1 + 1 = 2
\end{equation}
\label{eq:2.1}
\myequations{sum}

\begin{equation}
    1 + 1 = 2
\end{equation}
\label{eq:2.2}
\myequations{sum}

\end{document}

答案1

我使用以下方法找到了解决方案标题安全包。它包括设置 tocloft 以使用标题选项:

\usepackage[titles]{tocloft}

然后将章节标题设置为居中:

\titleformat{\chapter}[block]{\LARGE\bfseries\filcenter}{}{1em}{}% center title of chapters

然后将它们恢复为默认值(或您想要的布局)[我已经根据这个问题]

\newcommand{\oldchap}{% new command to return to default layout
    \titleformat{\chapter}[display]
    {\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
    \titlespacing*{\chapter} {0pt}{50pt}{40pt}}

    \oldchap %command to be called

这是一个完整的工作示例:

\documentclass[12pt]{report}
\usepackage{titlesec}
\usepackage[titles]{tocloft}
\usepackage[a4paper,width=150mm,top=25mm,bottom=25mm,bindingoffset=6mm]{geometry}

%%gmedina solution
\newcommand{\listequationsname}{List of Equations}
\newlistof{myequations}{equ}{\listequationsname}
\newcommand{\myequations}[1]{%
\addcontentsline{equ}{myequations}{\protect\numberline{\theequation}#1}\par}
\setlength{\cftmyequationsnumwidth}{2.5em}% Width of equation number in List of Equations

\begin{document}

\titleformat{\chapter}[block]{\LARGE\bfseries\filcenter}{}{1em}{}% center title of chapters
\listofmyequations

\newcommand{\oldchap}{%new command to return to default layout
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titlespacing*{\chapter} {0pt}{50pt}{40pt}}

\oldchap %command to be called
\chapter{sums}

\begin{equation}
    1 + 1 = 2
\end{equation}
\label{eq:2.1}
\myequations{sum}

\begin{equation}
    1 + 1 = 2
\end{equation}
\label{eq:2.2}
\myequations{sum}

\end{document}

相关内容