精美章节对齐

精美章节对齐

我正在处理一些代码行以获得有关章节标题的奇特样式。我使用以下代码:

\documentclass[11pt]{report}
\usepackage[T1]{fontenc}
\usepackage{titlesec}
\usepackage{xcolor}
\usepackage{blindtext}

\newcommand{\chapnumfont}{%     % define font for chapter number
  \usefont{T1}{pnc}{b}{n}%      % choose New Chancery, bold, normal shape
  \fontsize{100}{100}%          % font size 100pt, baselineskip 100pt
  \selectfont%                  % activate font
}
\colorlet{chapnumcol}{gray!75}  % color for chapter number

\titleformat{\chapter}[display]
{\filleft\bfseries}
{\filleft\chapnumfont\textcolor{chapnumcol}{\thechapter}}
{-24pt}
{\Huge}

\begin{document}

\tableofcontents
\listoftables
  \blinddocument

\end{document}

在此处输入图片描述

您可以将上图视为结果的示例。

现在我对摘要、目录、图片列表和表格列表有点问题。它们遵循章节标题的对齐方式(即在右侧),但我希望它们在纸张左侧对齐,只留下章节标题在右侧。有人能建议我解决该问题所需的代码行吗?

谢谢你!

答案1

如果你想全部你需要无数的左对齐章节

\titleformat{name=\chapter,numberless}[]...

\documentclass[11pt]{report}
\usepackage[T1]{fontenc}
\usepackage{titlesec}
\usepackage{xcolor}
\usepackage{blindtext}

\newcommand{\chapnumfont}{%     % define font for chapter number
 \usefont{T1}{pnc}{b}{n}%      % choose New Chancery, bold, normal shape
 \fontsize{100}{100}%          % font size 100pt, baselineskip 100pt
 \selectfont%                  % activate font
}
\colorlet{chapnumcol}{gray!75}  % color for chapter number

\titleformat{name=\chapter}[display]
{\filleft\bfseries}
{\filleft\chapnumfont\textcolor{chapnumcol}{\thechapter}}
{-24pt}
{\Huge}

\titleformat{name=\chapter,numberless}[display]
{\filright\bfseries}
{\filright}
{-24pt}
{\Huge}

\begin{document}
 
\tableofcontents
\listoftables

\blinddocument
 
\end{document}

如果您不仅希望编号章节右对齐,还希望其他章节(如简介或致谢)右对齐,您可以\titleformat在组内使用。

\documentclass[11pt]{report}
\usepackage[T1]{fontenc}
\usepackage{titlesec}
\usepackage{xcolor}
\usepackage{blindtext}

\newcommand{\chapnumfont}{%     % define font for chapter number
 \usefont{T1}{pnc}{b}{n}%      % choose New Chancery, bold, normal shape
 \fontsize{100}{100}%          % font size 100pt, baselineskip 100pt
 \selectfont%                  % activate font
}
\colorlet{chapnumcol}{gray!75}  % color for chapter number        

\begin{document}
 
\tableofcontents
\listoftables
 
\begingroup
 
 \titleformat{\chapter}[display]
 {\filleft\bfseries}
 {\filleft\chapnumfont\textcolor{chapnumcol}{\thechapter}}
 {-24pt}
 {\Huge}
 
 \blinddocument
 
\endgroup 
 
\chapter*{Acknowledgments}
 
\end{document}    

相关内容