如何创建章节的奇特风格

如何创建章节的奇特风格

我想在书籍类中开始一个采用花式章节样式的新文档。下面的草图概述了这个想法。基本上,我想在章节环境中有一个小目录。我还想在左侧粉红色条带上垂直写上白色文字“目录”一词。此粉红色条带应垂直向下延伸,直到目录末尾。章节号应位于白色圆圈内(我选择在这里使用 10 而不是 1,以强调章节号应位于圆圈内中央并与章节标题水平对齐)。花式章节样式应占据文本的宽度,章节内容应紧随其后(因此不在新页面上)。

如果有人能使用 LaTeX 技能帮助我重新创建这一章节风格,我将不胜感激。

在此处输入图片描述

答案1

这可能会帮助你入门,至少在一个最小的例子中这是可行的。

\documentclass{report}

\usepackage[explicit]{titlesec}
\usepackage{titletoc}
\usepackage{tikz}

\colorlet{chaptercolorA}{violet}
\colorlet{chaptercolorB}{pink!70}
\newlength\chapterrulewd\setlength\chapterrulewd{1cm}
\newlength\chapterruledist\setlength\chapterruledist{0.25cm}
\newlength\chapterruleover\setlength\chapterruleover{0.25cm}
\newlength\chapterbubblewd\setlength\chapterbubblewd{2pt}

\titleformat\chapter[block]
  {\sffamily\startcontents[chapter]}
  {}
  {0pt}
  {%
    \begin{tikzpicture}
      [
        titletext/.style=%
          {%
             text=chaptercolorA
            % to get nice spacing regardless of ascenders or descenders, if you
            % change the \chapterrulewd you'll need to adjust these
            ,text height=.615\chapterrulewd
            ,text depth=.385\chapterrulewd
          }
      ]
      \node
        [
           text width=\linewidth-\chapterruledist-\chapterrulewd-\chapterruleover
          ,text=chaptercolorA
          ,inner sep=0pt
        ]
        (toc)
        {%
          \printcontents[chapter]{}{1}[\value{secnumdepth}]
            {%
              % {level}[indent of entry text]{}{numwd}{dotspace}
              \dottedcontents{section}[2.3em]{}{2.3em}{4pt}%
              \dottedcontents{subsection}[5.5em]{}{3.2em}{4pt}%
              % add more formatting levels here if you need them
            }%
        };
      \path
        (toc.north west)
          ++(-\chapterruledist-.5\chapterrulewd,\chapterruledist+\chapterrulewd) 
          coordinate (tl)
        (toc.south west-|tl) coordinate (bl)
        (toc.north east|-tl)++(\chapterruleover,0) coordinate (tr)
        (tl)++(.5\chapterrulewd,-.5\chapterrulewd) coordinate (bb)
        ;
      \draw[line width=\chapterrulewd,chaptercolorA] (bl) -- (tl) -- (tr);
      \node[rotate=90,anchor=east,text=white,inner sep=0]
        at (tl|-toc.north)
        {Contents};
      \node
        [
          anchor=west, fill=chaptercolorB, line width=0,
          inner ysep=0,inner xsep=1cm, titletext
        ]
        at (bb) {#1};
      \draw[chaptercolorB,line width=\chapterbubblewd,fill=white]
        (bb) circle[radius=0.5*(\chapterrulewd-\chapterbubblewd)];
      \node[titletext] at (bb) {\thechapter};
    \end{tikzpicture}%
  }
% some spacing adjustments if you need them
\titlespacing*\chapter{0pt}{0pt}{0pt}[0pt]

\begin{document}
\setcounter{chapter}{9}
\chapter{One Chapter}
\section{One A}
\section{One B}
\subsection{One B 1}
\subsubsection{One B 1 a}
\subsubsection{One B 1 b}
\subsection{One B 2}
intriguing text
\end{document}

在此处输入图片描述

相关内容