带有装饰分隔符的章节标题

带有装饰分隔符的章节标题

我可以在哪里找到这里所示的装饰分隔符?

在此处输入图片描述

我想将它添加到下面的(几乎完成的)章节标题中。注意:我使用的程序(Latexian)安装了最常见的软件包,但不允许您加载新软件包(据我所知)。例如,我不能使用 pgfornaments。

\documentclass{report}

\makeatletter
\def\@makechapterhead#1{%
    \vspace*{-5em}% Space above number
    {\parindent \z@  \normalfont
    \interlinepenalty\@M
    \LARGE\centering \textbf{\itshape\thechapter}%
    \par\vspace{0.5em}% Space between number and title
    {\LARGE\itshape#1}%
    \par\vspace{4em}% Space between title and text
}}
\makeatother

\begin{document}

\chapter{Chapter title}

\end{document}

答案1

您选择的编辑器不会影响您可以安装的软件包。您可以更新 TeX 发行版,安装其他软件包、类和字体,并创建独立于编辑器的软件包、类和字体。也就是说,您的编辑器不会阻止您使用pgfornaments,我假设没有其他东西会阻止您使用,所以如果您喜欢它的装饰,您当然应该安装和使用它。

decorule提供装饰性、膨胀的规则,它不依赖于安装额外的装饰或字体。相反,它从所有 TeX 发行版中包含的字符创建规则。然而,结果可以预见地不如适当的印刷装饰那么令人满意。

装饰规则

\documentclass{report}

\makeatletter
\def\@makechapterhead#1{%
    \vspace*{-5em}% Space above number
    {\parindent \z@  \normalfont
    \interlinepenalty\@M
    \LARGE\centering \textbf{\itshape\thechapter}%
    \decorule
    \par\vspace{0.5em}% Space between number and title
    {\LARGE\itshape#1}%
    \par\vspace{4em}% Space between title and text
}}
\makeatother
\usepackage{decorule}

\begin{document}

\chapter{Chapter title}

\end{document}

或者你可以尝试swrule。同样,不需要安装任何特殊的东西。但是,我从来没有设法产生令人满意的结果:

膨胀规则

\documentclass{report}

\makeatletter
\def\@makechapterhead#1{%
    \vspace*{-5em}% Space above number
    {\parindent \z@  \normalfont
    \interlinepenalty\@M
    \LARGE\centering \textbf{\itshape\thechapter}%
    \par\vspace{0.25em}% Space between number and title
    \mbox{}\swrulex{.3\textwidth}{.25pt}{3.5pt}
    \par\vspace{0.25em}% Space between number and title
    {\LARGE\itshape#1}%
    \par\vspace{4em}% Space between title and text
}}
\makeatother
\usepackage{swrule}
\begin{document}

\chapter{Chapter title}

\end{document}

如果你不介意开销的话,你可以画一个:

绘制规则

\documentclass{report}
\usepackage{tikz}
\newsavebox{\myrule}
\sbox{\myrule}{\tikz {\path [fill, draw] (0,0) [out=0, in=180] to +(.125\textwidth,1pt) [out=0, in=180] to +(.125\textwidth,-1pt) [out=180, in=0] to +(-.125\textwidth,-1pt) [out=180, in=0] to cycle;}}
\makeatletter
\def\@makechapterhead#1{%
    \vspace*{-5em}% Space above number
    {\parindent \z@  \normalfont
    \interlinepenalty\@M
    \LARGE\centering \textbf{\itshape\thechapter}%
    \par\vspace{0.25em}% Space between number and title
    \usebox{\myrule}%
    \par\vspace{0.25em}% Space between number and title
    {\LARGE\itshape#1}%
    \par\vspace{4em}% Space between title and text
}}
\makeatother
\begin{document}

\chapter{Chapter title}

\end{document}

创建框的优点\myrule是,无论使用多少次,TikZ 图片都只需为文档渲染一次。但是,如果您希望能够更改文档中规则的长度,则命令会更好用:

\documentclass{report}
\usepackage{tikz}
\newcommand*\myrule[1][.25\textwidth]{%
  \tikz {\path [fill, draw] (0,0) [out=0, in=180] to +(.5*#1,1pt) [out=0, in=180] to +(.5*#1,-1pt) [out=180, in=0] to +(-.5*#1,-1pt) [out=180, in=0] to cycle;}}
\makeatletter
\def\@makechapterhead#1{%
    \vspace*{-5em}% Space above number
    {\parindent \z@  \normalfont
    \interlinepenalty\@M
    \LARGE\centering \textbf{\itshape\thechapter}%
    \par\vspace{0.25em}% Space between number and title
    \myrule%
    \par\vspace{0.25em}% Space between number and title
    {\LARGE\itshape#1}%
    \par\vspace{4em}% Space between title and text
}}
\makeatother
\begin{document}

\chapter{Chapter title}

\end{document}

此处,默认情况下\myrule.25\textwidth,但\myrule[some length]将覆盖该默认值。例如,\myrule[.1\textwidth]将生成

较短规则

然后可以对其进行调整,以允许在文档中根据需要更改长度:

\documentclass{report}
\usepackage{tikz}
\newcommand*\myrule[1][.25\textwidth]{%
  \tikz {\path [fill, draw] (0,0) [out=0, in=180] to +(.5*#1,1pt) [out=0, in=180] to +(.5*#1,-1pt) [out=180, in=0] to +(-.5*#1,-1pt) [out=180, in=0] to cycle;}}
\newlength\myrulelength
\setlength{\myrulelength}{.1\textwidth}
\makeatletter
\def\@makechapterhead#1{%
    \vspace*{-5em}% Space above number
    {\parindent \z@  \normalfont
    \interlinepenalty\@M
    \LARGE\centering \textbf{\itshape\thechapter}%
    \par\vspace{0.25em}% Space between number and title
    \myrule[\myrulelength]%
    \par\vspace{0.25em}% Space between number and title
    {\LARGE\itshape#1}%
    \par\vspace{4em}% Space between title and text
}}
\makeatother
\begin{document}
\let\clearpage\relax% only for testing!

\chapter{Chapter title}

\setlength\myrulelength{.2\textwidth}
\chapter{Another chapter title}

\end{document}

可变长度规则

要使长度根据章节标题的长度自动调整,您可以尝试以下操作:

\documentclass{report}
\usepackage{tikz}
\newcommand*\myrule[1][.25\textwidth]{%
  \tikz {\path [fill, draw] (0,0) [out=0, in=180] to +(.5*#1,1pt) [out=0, in=180] to +(.5*#1,-1pt) [out=180, in=0] to +(-.5*#1,-1pt) [out=180, in=0] to cycle;}}
\newlength\myrulelength
\setlength{\myrulelength}{.1\textwidth}
\makeatletter
\def\@makechapterhead#1{%
    \vspace*{-5em}% Space above number
    {\parindent \z@  \normalfont
    \interlinepenalty\@M
    \LARGE\centering \textbf{\itshape\thechapter}%
    \settowidth{\myrulelength}{\LARGE\itshape#1}%
    \par\vspace{0.25em}% Space between number and title
    \myrule[.8\myrulelength]%
    \par\vspace{0.25em}% Space between number and title
    {\LARGE\itshape#1}%
    \par\vspace{4em}% Space between title and text
}}
\makeatother
\begin{document}
\let\clearpage\relax% only for testing!

\chapter{Chapter title}

\chapter{Another chapter title}

\end{document}

自动变量规则

相关内容