目录宽度,标题中的 \MakeUppercase 字体较小,章节旁边有圆点

目录宽度,标题中的 \MakeUppercase 字体较小,章节旁边有圆点
  1. 如何让 ToC 更宽?1a. 如何让 ToC 更高?[章节下方、下一章之前有更多空间]

  2. 如何在章节旁边添加圆点?

  3. 如何在奇数侧放置当前章节名称但不放置章节——右侧只放置章节编号和章节名称 [左侧——页码],在偶数侧放置书籍标题 [右侧——页码]。两者都使用 \MakeUppercase,但字体较小。

     \documentclass[openany, 10pt]{book}
     \usepackage{xcolor}
     \usepackage[explicit]{titlesec}
     \usepackage[dotinlabels]{titletoc}
    
     \newlength\BoxWd
     \setlength\BoxWd{1cm}
     \newlength\Aux
    
     % chapter tiltes formatting
     \titleformat{\chapter}[display]
        {\normalfont\sffamily\bfseries\LARGE}
        {\renewcommand{\thechapter}{\Roman{chapter}}%
          \settowidth\Aux{\textcolor{white}{\Huge\thechapter}}
          \ifnum\Aux>\BoxWd
           \setlength\BoxWd{\Aux}
          \else\fi
          \hspace*{0.5em}\colorbox{black}{%
          \parbox[c][1.2cm][c]{\BoxWd}{%
           \centering\textcolor{white}{\Huge\thechapter}}}}
       {-1ex}
       {\titlerule\vspace{.7ex}\filleft\MakeUppercase{#1}}
       [\vspace{.2ex}\titlerule]
       % chapter tiltes spacing
       \titlespacing*{\chapter}{0pt}{50pt}{80pt}
    
       % section tiltes formatting
       \titleformat{\section}
         {\normalfont\Large\bfseries}{\MySecSquare\ \thesection}{1em}{#1}
    
       % formatting for chapter entries in ToC  
       \titlecontents{chapter}
        [1.5em]{}
        {\sffamily\bfseries\contentslabel{1.5em}}
        {\hspace*{-1.5em}}
        {\hfill\sffamily\bfseries\contentspage}
       % formatting for section entries in ToC  
       \titlecontents{section}
        [3.8em]{}
        {\sffamily\contentslabel{2.3em}}
        {\hspace*{-2.3em}}
        {\titlerule*[1pc]{.}\sffamily\contentspage}
    
       % Square to be used in itemize
       \newcommand\MySquare{%
         \leavevmode\hbox to 1.2ex{\hss\vrule height .9ex width .7ex depth -.2ex\hss}}
       % Square to be used in section titles
       \newcommand\MySecSquare{%
       \leavevmode\hbox to 1.2ex{\hss\vrule height 1.3ex width 1.1ex depth -.2ex\hss}}
    
       % First level of itemize uses a square
       \renewcommand\labelitemi{\MySquare}
    
       \begin{document}
    
       \tableofcontents
    
       \chapter{Test Chapter 1}
        \section{Test Section 1}
        \section{Test Section 2}
        \section*{Test Section 3}
       \chapter{Test Chapter 2}
       \chapter{Test Chapter 3}
       \chapter{Test Chapter 4}
       \chapter{Test Chapter 5}
       \chapter{Test Chapter 6}
       \chapter{Test Chapter 7}
       \chapter{Test Chapter 8}
       \chapter{Test Chapter 9}
    
       \end{document}
    

这是一个后续问题:书籍布局目录、章节、部分、

答案1

这是一个可能的解决方案;我使用该titleps包定义了一个具有所需设置的新页面样式(请确保安装了更新的 LaTeX 系统)。使用(来自该包)titleps完成了在目录中为章节条目添加点的修改。\titlerule*titletoc

\documentclass{book}
\usepackage{xcolor}
\usepackage[explicit]{titlesec}
\usepackage[dotinlabels]{titletoc}
\usepackage{titleps}
\usepackage{lipsum}

\newlength\BoxWd
\setlength\BoxWd{1cm}
\newlength\Aux

% chapter tiltes formatting
\titleformat{\chapter}[display]
  {\normalfont\sffamily\bfseries\LARGE}
  {\renewcommand{\thechapter}{\Roman{chapter}}%
    \settowidth\Aux{\textcolor{white}{\Huge\thechapter}}
    \ifnum\Aux>\BoxWd
      \setlength\BoxWd{\Aux}
    \else\fi
    \hspace*{0.5em}\colorbox{black}{%
    \parbox[c][1.2cm][c]{\BoxWd}{%
      \centering\textcolor{white}{\Huge\thechapter}}}}
  {-1ex}
  {\titlerule\vspace{.7ex}\filleft\MakeUppercase{#1}}
  [\vspace{.2ex}\titlerule]
% chapter tiltes spacing
\titlespacing*{\chapter}{0pt}{50pt}{80pt}

% section tiltes formatting
\titleformat{\section}
  {\normalfont\Large\bfseries}{\MySecSquare\ \thesection}{1em}{#1}

% formatting for chapter entries in ToC  
\titlecontents{chapter}
  [1.5em]{}
  {\sffamily\bfseries\contentslabel{1.5em}}
  {\hspace*{-1.5em}}
  {\titlerule*[1pc]{.}\sffamily\bfseries\contentspage}
% formatting for section entries in ToC  
\titlecontents{section}
  [3.8em]{}
  {\sffamily\contentslabel{2.3em}}
  {\hspace*{-2.3em}}
  {\titlerule*[1pc]{.}\sffamily\contentspage}

% Square to be used in itemize
\newcommand\MySquare{%
  \leavevmode\hbox to 1.2ex{\hss\vrule height .9ex width .7ex depth -.2ex\hss}}
% Square to be used in section titles
\newcommand\MySecSquare{%
  \leavevmode\hbox to 1.2ex{\hss\vrule height 1.3ex width 1.1ex depth -.2ex\hss}}

% First level of itemize uses a square
\renewcommand\labelitemi{\MySquare}

% Command to store the book title
\newcommand\MyTitle{The Title of The Book}

% definition of new page style
\newpagestyle{mystyle}[\footnotesize]{
\sethead[\MakeUppercase{\MyTitle}][][\thepage]
{\thepage}{}{\thechapter\ \MakeUppercase{\chaptertitle}}}
\pagestyle{mystyle}

\begin{document}

\tableofcontents

\chapter{Test Chapter One}
\section{Test Section One One}
\lipsum[1-20]
\chapter{Test Chapter Two}

\end{document}

一些说明所要求的修改的图像:

目录:

在此处输入图片描述

一些页面的顶部显示了标题:

在此处输入图片描述

在此处输入图片描述

如果 titleps 包不可用,也可以使用 fancyhdr 包生成所需的页面样式;使用此包,您需要替换以下行

\usepackage{titleps}

% definition of new page style
\newpagestyle{mystyle}[\footnotesize]{
\sethead[\MakeUppercase{\MyTitle}][][\thepage]
{\thepage}{}{\thechapter\ \MakeUppercase{\chaptertitle}}}
\pagestyle{mystyle}

\usepackage{fancyhdr}

% definition of new page style
\fancyhf{}
\fancyhead[ER,OL]{\thepage}
\fancyhead[EL]{\footnotesize\MakeUppercase{\MyTitle}}
\fancyhead[OR]{\footnotesize\MakeUppercase{\leftmark}}
\renewcommand\headrulewidth{0pt}

\pagestyle{fancy}
\renewcommand\chaptermark[1]{\markboth{\thechapter.\ #1}{}} 

在上面的示例代码中。

相关内容