Section Titles – Chapter Headings on the Side with Ornaments in LaTeX

pgfornamentsection-titles

I'd love for the book I'm writing to have subsections headed as in this book I read recently, appearing at the side within an ornament. What's a reasonable way to obtain such?

enter image description here

Best Answer

While TikZ isn't actually needed for this, it does make aligning the text and clip art easier.

\documentclass{article}
\usepackage{tikz}
\usepackage{lipsum}

\newsavebox{\decorationbox}
\savebox{\decorationbox}{\includegraphics[height={\dimexpr 5\baselineskip-2pt}, width=4cm] {example-image}}% clip art for frame

\newlength{\decorationmargin}
\setlength{\decorationmargin}{\dimexpr \textwidth-\wd\decorationbox+\marginparwidth}

\newcommand{\decoration}[1]% #1 = text
{\par\parshape=7
  0pt \textwidth
  0pt \decorationmargin
  0pt \decorationmargin
  0pt \decorationmargin
  0pt \decorationmargin
  0pt \decorationmargin
  0pt \textwidth
  \leavevmode\marginpar{\strut\hrule height0pt % align top of tikzpicture to bottom of \strut
    \hfill\llap{\begin{tikzpicture}% align right side of tikzpicture to right side of marginpar area 
      \node[inner sep=0pt] (DCbox) {\usebox\decorationbox};
      \node[draw,fill=white,text width=0.7\wd\decorationbox,font=\raggedright] at (DCbox.center) {#1};
    \end{tikzpicture}}}%
\ignorespaces}

\begin{document}

\decoration{This is a test}
\lipsum[1-2]
    
\end{document}

demo

Related Question