0

I would like to start a new document in the book class that adopts a fancy style of chapter. The idea is outlined in the sketch drawing below. Basically, I'd like to have a small table of contents inside the chapter environment. I'd also like to have the word 'Contents' in white text written vertically along the left-hand pink strip. This pink strip should extend vertically downwards until the end of the table of contents. The chapter number should be in the white circle (I've chosen to use 10 instead of 1 here to reinforce that the chapter number should be centred within the circle and horizontally level with the chapter title). The fancy chapter style should take up the width of the text, and the contents of the chapter should follow on immediately (so not on a new page).

I'd really appreciate if if anyone could use their LaTeX skills to help me recreate this chapter style.

enter image description here

wrb98
  • 876
  • First, check out https://tex.stackexchange.com/questions/1319/showcase-of-beautiful-typography-done-in-tex-friends/74609?r=SearchResults&s=1%7C0.0000#74609 for inspiration. – John Kormylo Mar 04 '23 at 05:04
  • Hi John. I've already looked at the given thread. My skills are not yet at the level where I could attempt something like this. – wrb98 Mar 04 '23 at 06:25
  • article doesn't have \chapters, wouldn't it make more sense to start off with report or book? – Skillmon Mar 04 '23 at 12:54
  • Also: what should happen to unnumbered chapters, is there a top-level ToC, should it be formatted similarly? – Skillmon Mar 04 '23 at 13:09
  • Ah, book would probably work better then. There won't be any unnumbered chapters or a top-level TOC in the document I have in mind. Hope that helps. Will update the question. – wrb98 Mar 04 '23 at 14:37
  • Provide an MWE (from \documentclass... to \end{document}} that we can compile that shows the problem and what you have done to solve it. This is not a "do it for me" site. – Peter Wilson Mar 04 '23 at 18:34
  • Seems to me this can be achieved using tcolorbox (or tikz) and titletoc . Look for example here and here. – alchemist Mar 04 '23 at 20:47

1 Answers1

3

This might get you started, at least in a minimal example this works.

\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}

enter image description here

Skillmon
  • 60,462
  • Very great work! Impressive! I don't know if there is a better solution, but if you embed \begin{tikzpicture}...\end{tikzpicture} in \makebox[0pt][l]{...} the overfull hbox warning (because the violet thick line goes a little in the margin) is gone. No so important for a warning, but if someone prefer not to have avoidable warnings… If needed, one can change the distance inner xsep to 1.065cm for better horizontal alignment ("One Chapter" above "One A"), but this value is good only if the size of the document class (here 10pt for report) isn't modified. report.cls has a hint about it? – quark67 Mar 05 '23 at 01:49
  • @quark67 what really makes me wonder is: The tikzpicture doesn't stick out into the margin (use showframe to check, it is \linewidth-wide), it seems that the box put around it by titlesec is somehow narrower than that (the warning is about 14.6pt, that should be very visible). – Skillmon Mar 05 '23 at 08:14
  • Yes, you're right. Strange. I don't know why there is this overfull hbox. Without the \makebox trick, adding \draw[line width=2mm,cyan] (tr) +(0,-5mm) -- + (-14.62pt,-5mm); after the draw of (bl) -- (tl) -- (tr); gives the overfull hbox of 14.6pt. But adding also \draw[line width=2mm,red] (tr) -- + (14.62pt,0pt); gives not an overfull hbox of 14.6+14.6 point, but only an overfull hbox of 17.9pt. Very interesting and intriguing problem here. – quark67 Mar 05 '23 at 09:05