2

The question posted here is an extension of the one posed in Looking to Insert a Figure and Wrap It Within a Customized Tikzpicture

Consider the following code

\documentclass[border=1cm]{book}
\usepackage{lipsum}

\usepackage{wrapfig} \usepackage[justification=centering]{caption} \usepackage{graphicx}

\usepackage{tikz} \usetikzlibrary{positioning} \usetikzlibrary{decorations.pathmorphing} \usetikzlibrary{shadows.blur} \usetikzlibrary{shadings}

\begin{document} \thispagestyle{empty}

\definecolor{pylight}{RGB}{247, 235, 205} \definecolor{py}{RGB}{243, 224, 181} \definecolor{pydark}{RGB}{221, 182, 110} \definecolor{pyhighlight}{RGB}{254, 235, 204}

\pgfdeclareverticalshading{parchment}{100bp}{% color(0bp)=(pydark); color(25bp)=(pydark); color(30bp)=(py); color(50bp)=(pylight); color(70bp)=(py); color(75bp)=(pydark); color(100bp)=(pydark)% } \pgfdeclareradialshading{rparchment}{\pgfpoint{0cm}{0cm}}{% color(0bp)=(pylight); color(13bp)=(pylight); color(20bp)=(py); color(40bp)=(pydark); color(60bp)=(pydark!50!black); color(100bp)=(black)% } \tikzset{ pencildraw/.style={% decorate, decoration={% random steps, segment length=1.1ex, amplitude=.5ex% } }, drop shadow/.style={ blur shadow={% shadow xshift=.5pt, shadow yshift=-.5pt, shadow blur steps=9, shadow blur extra rounding=1.5pt% }, }, parchment fill/.style={ pencildraw, fill=pyhighlight, postaction={shading=parchment, opacity=1}, postaction={shading=rparchment, opacity=.7} } }

\begin{tikzpicture} \shade node[preaction={fill=black,opacity=.5,transform canvas={xshift=1mm,yshift=-1mm}},parchment fill, drop shadow, inner sep=5mm] {\parbox{0.87\textwidth}{\fontsize{13}{16}\selectfont \hangindent=\dimexpr 0.2\textwidth+\columnsep\relax \hangafter=-4 \noindent\llap{\raisebox{\dimexpr 0.6\baselineskip-\height}[0pt][0pt]% overlap indentation {\includegraphics[width=0.2\textwidth]{example-image-a}}\hspace{\columnsep}}% \textbf{\textit{\lipsum[2]}}}} ; \end{tikzpicture} \end{document}

which produces the output

enter image description here

I would like to drop the paragraph a bit so that it does not start at the same height as the top of the inserted image, and hope that inserting \vspace{\baselineskip} immediately prior to \lipsum[2] might do the trick; but alas, it doesn't.

When I add the code

\begin{tikzpicture}
  \shade node[preaction={fill=black,opacity=.5,transform canvas={xshift=1mm,yshift=-1mm}},parchment fill, drop shadow,
    inner sep=5mm]
  {\parbox{0.87\textwidth}{\fontsize{13}{16}\selectfont 
    \hangindent=\dimexpr 0.2\textwidth+\columnsep\relax
    \hangafter=-4
    \noindent\llap{\raisebox{\dimexpr 0.6\baselineskip-\height}[0pt][0pt]% overlap indentation
      {\includegraphics[width=0.2\textwidth]{example-image-a}}\hspace{\columnsep}}%
    \textbf{\textit{\vspace{\baselineskip}\lipsum[2]}}}} ;
\end{tikzpicture}

the box I get is this:

enter image description here

I don't understand why the baselineskip seems to be occurring after the first line instead of prior to it. I have not had success by moving \vspace{\baselineskip} elsewhere.

QUESTION: Is there a simple way (using the given code) to lower the start of the paragraph a specified amount (say, a baselineskip) while maintaining the image at the fixed location? Depending upon the length of an actual paragraph, I may want to increase or decrease the length of which the paragraph is lowered---and so, I am hoping to accomplish this by a command or two, and not by making ``tweaking'' some combination of numerical values in the existing code.

Thank you.

DDS
  • 8,816
  • 4
  • 9
  • 36

1 Answers1

2

enter image description here

I defined a new length \zzz and set it to 10pt here,

  • increase the \raisebox of the image by \zzz so it sticks above the text.

  • add \vspace{\zzz} to move the whole construct down, so restoring the position of the image.

  • changed the \hangafter from -4 to -3 so only three lines cut in as less space needed for the image.

\documentclass[border=1cm]{book}
\usepackage{lipsum}

\usepackage{wrapfig} \usepackage[justification=centering]{caption} \usepackage{graphicx}

\usepackage{tikz} \usetikzlibrary{positioning} \usetikzlibrary{decorations.pathmorphing} \usetikzlibrary{shadows.blur} \usetikzlibrary{shadings}

\newlength\zzz \setlength\zzz{10pt}

\begin{document} \thispagestyle{empty}

\definecolor{pylight}{RGB}{247, 235, 205} \definecolor{py}{RGB}{243, 224, 181} \definecolor{pydark}{RGB}{221, 182, 110} \definecolor{pyhighlight}{RGB}{254, 235, 204}

\pgfdeclareverticalshading{parchment}{100bp}{% color(0bp)=(pydark); color(25bp)=(pydark); color(30bp)=(py); color(50bp)=(pylight); color(70bp)=(py); color(75bp)=(pydark); color(100bp)=(pydark)% } \pgfdeclareradialshading{rparchment}{\pgfpoint{0cm}{0cm}}{% color(0bp)=(pylight); color(13bp)=(pylight); color(20bp)=(py); color(40bp)=(pydark); color(60bp)=(pydark!50!black); color(100bp)=(black)% } \tikzset{ pencildraw/.style={% decorate, decoration={% random steps, segment length=1.1ex, amplitude=.5ex% } }, drop shadow/.style={ blur shadow={% shadow xshift=.5pt, shadow yshift=-.5pt, shadow blur steps=9, shadow blur extra rounding=1.5pt% }, }, parchment fill/.style={ pencildraw, fill=pyhighlight, postaction={shading=parchment, opacity=1}, postaction={shading=rparchment, opacity=.7} } }

\begin{tikzpicture} \shade node[preaction={fill=black,opacity=.5,transform canvas={xshift=1mm,yshift=-1mm}},parchment fill, drop shadow, inner sep=5mm] {\parbox{0.87\textwidth}{\fontsize{13}{16}\selectfont \vspace{\zzz}% \hangindent=\dimexpr 0.2\textwidth+\columnsep\relax \hangafter=-3 \noindent\llap{\raisebox{\dimexpr \zzz+0.6\baselineskip-\height}[0pt][0pt]% overlap indentation {\includegraphics[width=0.2\textwidth]{example-image-a}}\hspace{\columnsep}}% \textbf{\textit{\lipsum[2]}}}} ; \end{tikzpicture} \end{document}

David Carlisle
  • 757,742
  • Thank you for this fine answer. If I may, I would like to ask if you think it possible to lower the paragraph directly within the tikzpicture itself? The reason is that, on occasion, I produce many of them---so I wouldn't necessarily want to lower every paragraph by zzz; only some. With your answer, I can introduce other variable amounts, say xxx, yyy, etc. to solve the problem. But it would be easier if I could do it ``on the fly'' as needed. Thank you again for your very helpful answer. – DDS Aug 17 '21 at 21:52
  • @mlchristians not sure I understand what you mean, \zzz is only used (twice) within the tikzpicture. You don't need separate length registers, you can set the value locally in each instance, if you repeat the construct but put \setlength\zzz{20pt} before the second one, it will look different – David Carlisle Aug 17 '21 at 21:55
  • Sorry. \vspace{\zzz} – DDS Aug 17 '21 at 21:56
  • @mlchristians as I say I don't understand the comment, You can set the length to 0pt so no change by default then set it locally on any instances that need adjustment – David Carlisle Aug 17 '21 at 21:58
  • Right. But if I produce multiple such pictures in the same document (add one, compile; add another, compile; etc. ) and encounter one where the paragraph has to be dropped---\zzz is fine for the first; but the next one I will have to go back to the Preamble, introduce another length, say \yyy for the second, \xxx for the third case, and so forth. It would be easier (it may not be possible) to find an auspicious place in the tikzpicture and insert, say, \vspace{10pt}, though I have never found such an auspicious place. – DDS Aug 17 '21 at 22:10
  • I am grateful for your answer as it works very nicely and will suit my needs when multiple pictures are in the same document---should what I am hoping to find not be possible. – DDS Aug 17 '21 at 22:11
  • @mlchristians I can not understand why you would need \yyy you can set the offset value (called zzz here) to different values in each case. You don't need to set any value in the preamble. – David Carlisle Aug 17 '21 at 22:14
  • For example, if I compile tikz1 with \zzz=10pt and later, in the same document, tikz20 with \zzz=20pt, tikz1 will recompile with a 20pt descent instead of 10pt. But like I said earlier, your answer as posted will indeed be fine for me: I will just have to add different length names in the Preamble as I generate new tikzpictures. Thank you again, your answer is indeed helpful to me. – DDS Aug 17 '21 at 22:51
  • @mlchristians why do you think setting the value for the second one will have any effect on the first???? There is absolutely no reason to duplicate the length register, – David Carlisle Aug 17 '21 at 22:56