3

I have a tikzpicture:

enter image description here

which was produced by the following code.

\documentclass{book}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{color}
\usepackage{tikz}

\newlength\drop % To drop the start of the paragraph below the top of the picture.
\setlength\drop{10pt}

\begin{document}
\thispagestyle{empty}

\begin{tikzpicture}
  \shade node[preaction={fill=black,opacity=.5,},fill=blue!25, inner sep=5mm]
  {\parbox{0.87\textwidth}{\fontsize{12}{13}\selectfont
    \vspace{\drop}%
    \hangindent=\dimexpr 0.2\textwidth+\columnsep\relax
    \hangafter=-4
    \noindent\llap{\raisebox{\dimexpr \drop+0.6\baselineskip-\height}[0pt][0pt]% overlap indentation
      {\includegraphics[width=0.2\textwidth]{example-image-c}}\hspace{\columnsep}}% 
      This is the first sentence. \\  
      %This is the first sentence. \vspace*{12pt}  
      %This is the first sentence. \vskip 12pt  
      \textbf{\textit{\lipsum[2]}}}} ;
\end{tikzpicture}
\end{document}

However, when I would like to increase the space between the first sentence and the Latin by replacing This is the first sentence. \\ by This is the first sentence. \vspace*{12pt} and then This is the first sentence. \vskip 12pt, I get, respectively,

enter image description here

and

enter image description here

QUESTION Does anyone know why this happens and how to fix it? This tikzpicture seems to finely handle sentences as long as they are either all part of a contiguous paragraph or separated by \\. Anything else seems to produce strange results. I'm thinking that if I could add a ``blank sentence'' after \\ I might be able to produce what I am looking for.

I posted a question along these lines the other day, but it attracted no answers. I have simplified both the tikzpicture and the question in the hope that somebody may point out the cause of the problem and how to correct it. I hope this is OK.

Thank you.

1
  • the behaviour you describe looks like standard paragraph linebreaking unrelated to tikz. vspace adds space after the current line as shown in your first image and vskip ends the current paragraph so ending the paragraph shape, as shown by your second image. Aug 25, 2021 at 19:10

2 Answers 2

4
\documentclass{book}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{color}
\usepackage{tikz}

\newlength\drop % To drop the start of the paragraph below the top of the picture.
\setlength\drop{10pt}

\begin{document}
\thispagestyle{empty}

\begin{tikzpicture}
  \shade node[preaction={fill=black,opacity=.5,},fill=blue!25, inner sep=5mm]
  {\parbox{0.87\textwidth}{\fontsize{12}{13}\selectfont
    \vspace{\drop}%
    \hangindent=\dimexpr 0.2\textwidth+\columnsep\relax
    \hangafter=-4
    \noindent\llap{\raisebox{\dimexpr \drop+0.6\baselineskip-\height}[0pt][0pt]% overlap indentation
      {\includegraphics[width=0.2\textwidth]{example-image-c}}\hspace{\columnsep}}% 
      This is the first sentence.\\[-5pt]~\smallskip\\
%
      %This is the first sentence. \vspace*{12pt}  
      %This is the first sentence. \vskip 12pt  
      \textbf{\textit{\lipsum[2]}}}} ;
\end{tikzpicture}
\end{document}

enter image description here

2
  • Thank you once again for your help. I have worked on this problem often in the past with no success. Aug 25, 2021 at 19:19
  • @mlchristians It was more of a challenge than I at first thought. Without the \smallskip, the first line wanted to wrap in a very spaced out way. If you want only one line of the latin indented to the right of the figure, you need to use \\~\\~ (two linebreaks). Aug 25, 2021 at 19:22
3

This is not related to the surrounding tikz at all, it is just showing the normal LaTeX line breaking.

If you use \vspace mid line then the paragaph is broken in to lines as usual, and then the space is inserted after the current line, as shown in your first image.

Here you want a forced line break followed by a space, so the standard LaTeX \\[12pt] command can be used. As the line then takes up more space than "expected" I reduced the \hangafter from 4 to 3 so that only three lines are cut in.

enter image description here

\documentclass{book}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{color}
\usepackage{tikz}

\newlength\drop % To drop the start of the paragraph below the top of the picture.
\setlength\drop{10pt}

\begin{document}
\thispagestyle{empty}

\begin{tikzpicture}
  \shade node[preaction={fill=black,opacity=.5,},fill=blue!25, inner sep=5mm]
  {\parbox{0.87\textwidth}{\fontsize{12}{13}\selectfont
    \vspace{\drop}%
    \hangindent=\dimexpr 0.2\textwidth+\columnsep\relax
    \hangafter=-3
    \noindent\llap{\raisebox{\dimexpr \drop+0.6\baselineskip-\height}[0pt][0pt]% overlap indentation
      {\includegraphics[width=0.2\textwidth]{example-image-c}}\hspace{\columnsep}}% 
      This is the first sentence. \\[12pt] 
      \textbf{\textit{\lipsum[2]}}}} ;
\end{tikzpicture}
\end{document}
3
  • Does \\{12pt} redefine the length of \`? If not, what exactly does \\{12pt}` do? Also, is there a name for `\` so that I may know for future reference? Aug 25, 2021 at 20:48
  • @SamuelBowditch \\ is the standard latex command for a newline, and the optional argument is additional vertical space to be added after the linebreak. It doesn't actually redefine anything Aug 25, 2021 at 20:58
  • Thank you. And for my understanding, am I correct in interpreting your statement \\{12pt} as adding a 12pt vertical skip after the start of a new line initiated by \\ ? Aug 25, 2021 at 21:15

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.