侧面有章节标题,带有装饰

侧面有章节标题,带有装饰

我希望我正在写的书能有小节标题,就像我最近读的这本书一样,出现在装饰的侧面。有什么合理的方法可以实现这样的效果?

在此处输入图片描述

答案1

虽然实际上并不需要 TikZ,但它确实使对齐文本和剪贴画变得更容易。

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

演示

相关内容