如何創造精美的章節風格

如何創造精美的章節風格

我想在書籍類中開始一個新文檔,該文檔採用奇特的章節風格。下面的草圖概述了這個想法。基本上,我想在章節環境中有一個小目錄。我還希望沿著左側粉紅色條垂直書寫白色文字“內容”一詞。此粉紅色條應垂直向下延伸,直到目錄末尾。章節編號應位於白色圓圈內(我在這裡選擇使用 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}

在此輸入影像描述

相關內容