3

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

3
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.
    – Community Bot
    Dec 22, 2021 at 1:50
  • wrapfig with overhang could do it, but you have to start the wrapfigure in the middle of the paragraph, and provide the number of lines (five). Dec 22, 2021 at 5:15
  • you could also use a combination of \marginpar and \parshape (with overlap into the text area). Dec 22, 2021 at 5:19

1 Answer 1

4

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.