3

I want to add a TikZ picture beside a text block

\documentclass{article}
\usepackage{lipsum}
\usepackage{tikz}
\begin{document}
  \lipsum[1]
\begin{tikzpicture}[color=white]
\node[fill=blue!70,rotate=90] at (0,0) {Vertical Text on Left};
\end{tikzpicture}
  \lipsum[2]
  \lipsum[3]
\end{document}

but with this structure, the TikZ` picture is inserted at the first line of text, instead of placing side by side.

enter image description here

One solution can be using packages like wrapfig to wrap the text around picture. Isn't there any easier solution to place TikZ figure beside text?

Googlebot
  • 4,035

3 Answers3

3

Use \parbox, I just set the widths as a fraction of \linewidth.

\documentclass{article}
\usepackage{lipsum}
\usepackage{tikz}
\begin{document}
  \lipsum[1]
\noindent\parbox[][][t]{.05\linewidth}{\begin{tikzpicture}[color=white]
\node[fill=blue!70,rotate=90] at (0,0) {Vertical Text on Left};
\end{tikzpicture}}%
\parbox[][][t]{.95\linewidth}{
  \lipsum[2]
  \lipsum[3]
}
\end{document}

enter image description here

2

Just for reference, here's a solution with wrapfig:

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

\begin{document}
\lipsum[1]
\begin{wrapfigure}[10]{L}{.5cm}
\vspace{-\baselineskip}
\begin{tikzpicture}[color=white]
\node[fill=blue!70,rotate=90,minimum width=9\baselineskip,align=center]
at (0,0) {Vertical Text on Left};
\end{tikzpicture}
\end{wrapfigure}
\lipsum[2]
\lipsum[3]
\end{document}

(Author: Gonzalo Medina)

Paul Gaborit
  • 70,770
  • 10
  • 176
  • 283
0

Here is an answer using the minipage environment. For contrast, \strut is used in one place and \bigkip in another to improve spacing.

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

\begin{document}
\lipsum[1] \strut  
\noindent
\begin{minipage}{0.05\textwidth}
\begin{tikzpicture}[color=white]
    \node[fill=blue!70,rotate=90] at (0,0) {Vertical Text on Left};
\end{tikzpicture}
\end{minipage} \quad
\begin{minipage}{0.9\textwidth}
\lipsum[2]
\end{minipage}
\bigskip\lipsum[3]

\end{document}

enter image description here

zun
  • 814