使用 tocloft 格式化 TOC/LOF/LOT 字体

使用 tocloft 格式化 TOC/LOF/LOT 字体

我的出版商要求我更改 TOC/LOT/LOF 和章节的格式。遗憾的是,我对 LaTeX 和英语的掌握还不够深,无法从 titlesec 文档中看出端倪。

简而言之,我的任务是:

  • 章节标题大写,11.2pt,居中
  • 章节标题采用大写,10.2pt,居中
  • 子章节标题采用 10.2pt 常规大小写,居中
  • 小节标题为普通大小写,10.2pt,斜体

总有机碳/批次/总有机碳

  • 每个名称(目录,...)大写,11.2pt
  • 章节标题采用大写,11.2pt
  • 章节标题采用大写,10.2pt
  • 常规大小写的小节标题 10.2pt
  • 小节标题为普通大小写,10.2pt,斜体

而 MWE 则反映了我所尝试过的一切——我对 LaTeX 的理解已经达到了极限,并且无法理解为什么我所做的改变似乎毫无效果。

非常感谢您的帮助。

\documentclass[12pt,a4paper,twoside,openright]{report}
\usepackage[latin1]{inputenc}
\usepackage{lipsum}
\usepackage[english]{babel}
\usepackage{amsmath, amsfonts,amssymb}
\usepackage[titles]{tocloft}
\usepackage[explicit]{titlesec}

%Set depth in TOC
\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}

%Format of text font size and line spacing
\fontsize{10.2}{11.9}\selectfont

%TODO This is meant to be 11.2 in Uppercase   
\renewcommand{\cftchapfont}{\MakeUppercase{\fontsize{11.9}{11.9}}}

%TODO This is meant to be 10.2 in Uppercase
\renewcommand{\cftsecfont}{\MakeUppercase{\fontsize{10.2}{11.9}}}

%TOOO: This is meant to be 10.2 normal font
\renewcommand{\cftsubsecfont}{\fontsize{10.2}{11.9}} 

%TOOO: This is meant to be 10.2 normal font to be cursive 10.2
\renewcommand{\cftsubsubsecfont}{\fontsize{10.2}{11.9}} 

%TODO: This is meant to be 10.2 normal font to be cursive 10.2
\renewcommand{\cftloftitlefont} {\MakeUppercase{\fontsize{11.9}{11.9} \selectfont}}
\renewcommand{\cftlottitlefont} {\MakeUppercase{\fontsize{11.9}{11.9} \selectfont}}

%Filling lines w/ dots.
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}}
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}

\makeatletter
\def\@makechapterhead#1{%
    %%%%\vspace*{50\p@}% %%% removed!
    {\vskip 71.4\p@ %3x(11.9+11.9)
        \parindent \z@ \raggedright \fontsize{11.9}{11.9} \selectfont
        \ifnum \c@secnumdepth >\m@ne
        \fontsize{11.9}{11.9} \centering \selectfont \MakeUppercase{\@chapapp\space \thechapter}:
        %\par
        \nobreak
        %\vskip 11.9\p@
        \fi
        \interlinepenalty\@M
        \fontsize{11.9}{11.9} \MakeUppercase{#1}\par\nobreak
        \vskip 23.8\p@
}}
\def\@makeschapterhead#1{%
    %%%%%\vspace*{50\p@}% %%% removed!
    {\parindent \z@ \raggedright
        \fontsize{11.9}{11.9} \selectfont
        \interlinepenalty\@M
        \fontsize{11.9}{11.9} \selectfont  #1\par\nobreak
        \vskip 23.8\p@
}}


\renewcommand\section{\@startsection {section}{1}{\z@}%
    {44.2pt}% 2x(10.2+11.9)
    {22.1pt}%
    {\centering \fontsize{10.2}{11.9} \selectfont}}% from \Large

\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
    {44.2pt}% 2x(10.2+11.9)
    {22.1pt}%
    {\centering\fontsize{10.2}{11.9} \selectfont}}% from \Large

\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
    {44.2pt}% 2x(10.2+11.9)
    {22.1pt}%
    %\noindent
    {\centering \fontsize{10.2}{11.9} \selectfont}}% from \Large
\makeatother



\begin{document}
    % TODO: The headline should be in the same format as chapter font (11.2, uppercase)     
    \tableofcontents 

    % TODO: The headline should be in the same format as chapter font (11.2, uppercase)
    \listoffigures 

    % TODO: The headline should be in the same format as chapter font (11.2, uppercase)
    \listoftables 


    %The following is just filling the document for the TOC/LOT/LOF
    \chapter{Chapter One Title}
    \lipsum[1-4]
    \begin{figure}
        \caption[Figure 1 in chapter 1]{This is figure 1.2}
    \end{figure}
    \lipsum[1-2]
    \section{Section One}
    \lipsum[1-2]
    \subsection{Subsection One}
    \lipsum[1-2]
    \subsubsection{Subsubsection One}
    \lipsum[1-2]
    \begin{table}
        \caption[Table 1 in Chapter 1]{This is table 1.1}
        \begin{tabular}{ l c r }
            1 & 2 & 3 \\
            4 & 5 & 6 \\
            7 & 8 & 9 \\
        \end{tabular}
    \end{table}
    \lipsum
    \begin{figure}
        \caption[Figure 2 in chapter 1]{This is figure 1.2}
    \end{figure}
    \lipsum[1-4]
    \chapter{Chapter Two Title}
    \lipsum
    \chapter{Chapter Three Title}
    \lipsum
\end{document}

答案1

正如评论中提到的,你真的不应该一起使用titlesectocloft。该tocloft包旨在与标准类一起使用,但不适用于由修改的标题titlesec。由于您使用titlesec来格式化标题,因此您应该使用随附的titletoc包(由同一作者编写)来格式化目录。

这是一个示例文档,大致满足您的要求,应该足以让您根据需要进行修改。您没有指定任何垂直间距,我也没有深入研究您的代码,所以我只保留了标准类值report。您也没有指定任何标题是否应该加粗,但您可以\bfseries根据需要添加到标题定义中。

由于您要求的尺寸恰好是 11.2 和 10.2,因此我为这两个尺寸创建了两个命令,但由于主字体大小不是这两个命令中的任何一个,因此我不太清楚它们与 12pt 文档类选项有何关系。

\documentclass[12pt]{report}
\usepackage{kantlipsum}
\usepackage[explicit]{titlesec}
\usepackage{titletoc}
\newcommand{\elevenpt}{\fontsize{11.2}{12}\selectfont}
\newcommand{\tenpt}{\fontsize{10.2}{11}\selectfont}
\titleformat{\chapter}[block]{\elevenpt\filcenter}{\MakeUppercase\chaptertitlename\ \thechapter}{20pt}{\MakeUppercase{#1}}
\titleformat{\section}[block]{\tenpt\filcenter}{\thesection}{1em}{\MakeUppercase{#1}}
\titleformat{\subsection}[block]{\tenpt\filcenter}{\thesubsection}{1em}{#1}
\titleformat{\subsubsection}[hang]{\tenpt\itshape}{\thesubsubsection}{1em}{#1}
\titlespacing*{\chapter}{0pt}{50pt}{40pt}
\titlespacing*{\section}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\titlespacing*{\subsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\titlespacing*{\subsubsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\titlecontents{chapter}
              [3em] 
              {}
              {\elevenpt\contentslabel{2em}\MakeUppercase}
              {\hspace*{-2em}}
              {\titlerule*[1pc]{.}\contentspage}
\titlecontents{section}
              [5em]
              {}
              {\tenpt\contentslabel{2.3em}\MakeUppercase}
              {\hspace*{-2.3em}}
              {\titlerule*[1pc]{.}\contentspage}
\titlecontents{subsection}
              [7em] 
              {}
              {\tenpt\contentslabel{2.8em}}
              {\hspace*{-2.8em}}
              {\titlerule*[1pc]{.}\contentspage}
\titlecontents{subsubsection}
              [7em] 
              {}
              {\tenpt\itshape\contentslabel{3.5em}}
              {\tenpt\itshape\contentslabel{3.5em}}
              {\titlerule*[1pc]{.}\contentspage}
\setcounter{tocdepth}{4}
\begin{document}
\tableofcontents
\listoffigures
\chapter{A chapter level heading}
\kant[1]
\section{A section level heading}
\kant[2]
\subsection{A subsection level heading}
\kant[3]
\subsubsection{A subsubsection level heading}
\kant[4]
\begin{figure}
\caption{A figure}
\end{figure}
\end{document}

TOC 代码输出 样本标题

答案2

titlesec以下是使用和 的可能解决方案titletoc。您应该检查子节和子子节的间距要求,因为在我看来,它们看起来太大了。

\documentclass[12pt,a4paper,twoside,openright]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} 
\usepackage{lipsum}
\usepackage[english]{babel}
\usepackage{amsmath, amsfonts,amssymb}
\usepackage[showframe]{geometry} 
\usepackage[explicit]{titlesec}
\usepackage{titletoc} 
%Set depth in TOC
\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}

%Format of text font size and line spacing
\fontsize{10.2}{11.9}\selectfont

\titlecontents{chapter}[1.2em]
{\vspace{1ex}\fontsize{10.2}{11.9}\selectfont}%
{\contentslabel{1.4em}\MakeUppercase}%
{\MakeUppercase}%
{\titlerule*[1pc]{.}\contentspage}%
%
\titlecontents{section}[2.8em]
{\vspace{0.5ex}\fontsize{10.2}{11.9}\selectfont}%
{\contentslabel{1.8em}\MakeUppercase}%
{\MakeUppercase}%
{\titlerule*[1pc]{.}\contentspage}%
%
\titlecontents{subsection}[5em]
{\fontsize{10.2}{11.9}\selectfont}%
{\contentslabel{2.58em}}%
{}%
{\titlerule*[1pc]{.}\contentspage}%
%
\titlecontents{subsubsection}[5.7em]
{\fontsize{10.2}{11.9}\selectfont}%
{\contentslabel{3.4em}}%
{}%
{\titlerule*[1pc]{.}\contentspage}%

\titleformat{\chapter}{\fontsize{11.9}{11.9}\selectfont\filcenter\MakeUppercase}{\chaptername~\thechapter:}{10pt}{#1}
\titleformat{name = \chapter, numberless}{\fontsize{11.9}{11.9}\selectfont\filcenter\MakeUppercase}{}{0pt}{#1}
\titlespacing{\chapter}{0pt}{-13pt}{23.8pt}
%   
\titleformat{\section}{\fontsize{10.2}{11.9}\selectfont\filcenter\MakeUppercase}{\thesection}{8pt}{#1}
\titleformat{name = \section, numberless}{\fontsize{10.2}{11.9}\selectfont\filcenter\MakeUppercase}{}{0pt}{#1}
\titlespacing{\section}{0pt}{44.2pt}{22.1pt}
%
\titleformat{\subsection}{\fontsize{10.2}{11.9}\selectfont\filcenter}{\thesubsection}{8pt}{#1}
\titleformat{name = \subsection, numberless}{\fontsize{10.2}{11.9}\selectfont\filcenter}{}{0pt}{#1}
\titlespacing{\subsection}{0pt}{44.2pt}{22.1pt}
%
\titleformat{\subsubsection}{\fontsize{10.2}{11.9}\selectfont\itshape\filright}{\textup{\thesubsubsection}}{8pt}{#1}
\titleformat{name = \subsubsection, numberless}{\fontsize{10.2}{11.9}\selectfont\itshape\filright}{}{0pt}{#1}
\titlespacing{\subsubsection}{0pt}{44.2pt}{22.1pt}

\begin{document}
    % TODO: The headline should be in the same format as chapter font (11.2, uppercase)
    \tableofcontents

    % TODO: The headline should be in the same format as chapter font (11.2, uppercase)
    \listoffigures

    % TODO: The headline should be in the same format as chapter font (11.2, uppercase)
    \listoftables
    \chapter*{An Unnumbered Chapter}%
    \addcontentsline{toc}{chapter}{An Unnumbered Chapter}
    \lipsum[1-10]
    %The following is just filling the document for the TOC/LOT/LOF
    \chapter{Chapter One Title}
    \lipsum[1-4]
    \begin{figure}
        \caption[Figure 1 in chapter 1]{This is figure 1.2}
    \end{figure}
    \lipsum[1-2]
    \section{Section One}
    \lipsum[1-2]
    \subsection{Subsection One}
    \lipsum[1-2]
    \subsubsection{Subsubsection One}
    \lipsum[1-2]
    \begin{table}
        \caption[Table 1 in Chapter 1]{This is table 1.1}
        \begin{tabular}{ l c r }
            1 & 2 & 3 \\
            4 & 5 & 6 \\
            7 & 8 & 9 \\
        \end{tabular}
    \end{table}
    \lipsum
    \begin{figure}
        \caption[Figure 2 in chapter 1]{This is figure 1.2}
    \end{figure}
    \lipsum[1-4]
    \chapter{Chapter Two Title}
    \lipsum
    \chapter{Chapter Three Title}
    \lipsum

\end{document}

在此处输入图片描述 在此处输入图片描述 在此处输入图片描述 在此处输入图片描述

相关内容