Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
Short answer: no. –  Paul Gaborit Jul 19 '12 at 19:27
    
Y U NO love wrapfig? –  N3buchadnezzar Jul 19 '12 at 22:35
    
@N3buchadnezzar actually, I'm a big fan of wrapfig; just was curious if there is a simpler solution. –  All Jul 19 '12 at 22:55

3 Answers 3

up vote 2 down vote accepted

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

share|improve this answer
    
See How to keep a constant \baselineskip when using minipages (or \parboxes)? in terms of your vertical alignment. Perhaps all you need is a \strut in the last line of the paragraph preceding the \parbox (since it doesn't have any descenders). –  Werner Jul 19 '12 at 21:00
    
Can the blue rectangle span multiple pages? –  In PSTricks we trust Jul 19 '12 at 22:47

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)

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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