멋진 챕터 스타일을 만드는 방법

멋진 챕터 스타일을 만드는 방법

멋진 스타일의 챕터를 채택한 북 클래스에서 새 문서를 시작하고 싶습니다. 아이디어는 아래 스케치 그림에 요약되어 있습니다. 기본적으로 챕터 환경 내에 작은 목차를 갖고 싶습니다. 또한 왼쪽 분홍색 스트립을 따라 흰색 텍스트로 'Contents'라는 단어를 세로로 작성하고 싶습니다. 이 분홍색 스트립은 목차가 끝날 때까지 수직으로 아래쪽으로 확장되어야 합니다. 장 번호는 흰색 원 안에 있어야 합니다. 장 번호가 원 내 중앙에 있어야 하고 장 제목과 수평으로 수평이 되어야 한다는 점을 강조하기 위해 여기서는 1 대신 10을 사용하기로 선택했습니다. 화려한 장 스타일은 텍스트의 너비를 차지해야 하며, 장의 내용이 즉시 이어져야 합니다(새 페이지가 아니라).

누구든지 자신의 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}

여기에 이미지 설명을 입력하세요

관련 정보