为我的部分/章节设置样式

为我的部分/章节设置样式

我正在尝试在 LaTeX 上重现此章节/节的样式,并希望了解如何实现这一点。我一直在使用该secsty软件包,但尚未取得任何实际成果。

这个想法是让它代表我文档中的一个章节,但我想将其称为一个节并将我原来的节称为子节是没有问题的。在此处输入图片描述

谢谢,

答案1

您可以使用标题安全包;您可以将其作为起点的一个小例子:

\documentclass{book}
\usepackage[explicit]{titlesec}
\usepackage{lipsum}% just to generate text

\titleformat{\chapter}[display]
  {\normalfont\scshape\Huge}
  {\hspace*{-70pt}\thechapter.~#1}
  {-15pt}
  {\hspace*{-110pt}\rule{\dimexpr\textwidth+80pt\relax}{3pt}\Huge}
\titleformat{name=\chapter,numberless}[display]
  {\normalfont\scshape\Huge}
  {\hspace*{-70pt}#1}
  {-15pt}
  {\hspace*{-110pt}\rule{\dimexpr\textwidth+80pt\relax}{3pt}\Huge}
\titlespacing*{\chapter}{0pt}{0pt}{30pt}

\begin{document}
\tableofcontents
\chapter{Test Chapter}
\lipsum[1]
\end{document}

在此处输入图片描述

并进行了一些修改(在评论中请求),允许您使用包提供的功能更改规则的颜色xcolor

\documentclass{book}
\usepackage[explicit]{titlesec}
\usepackage{xcolor}
\usepackage{lipsum}% just to generate text

%\colorlet{myrulecolor}{black}
\definecolor{myrulecolor}{RGB}{150,20,0}% define the color for the rules

\titleformat{\chapter}[display]
  {\normalfont\scshape\Huge}
  {\hspace*{-70pt}\thechapter.~#1}
  {-15pt}
  {\hspace*{-110pt}{\color{myrulecolor}\rule{\dimexpr\textwidth+80pt\relax}{3pt}}\Huge}
\titleformat{name=\chapter,numberless}[display]
  {\normalfont\scshape\Huge}
  {\hspace*{-70pt}#1}
  {-15pt}
  {\hspace*{-110pt}{\color{myrulecolor}\rule{\dimexpr\textwidth+80pt\relax}{3pt}}\Huge}
\titlespacing*{\chapter}{0pt}{0pt}{30pt}

\begin{document}
\tableofcontents
\chapter{Test Chapter}
\lipsum[1]
\end{document}

在此处输入图片描述

相关内容