6

I am new to TikZ and I have a trivial question. How to draw a borderless diagram? In other words, I need something that does not displace the text. Similar to the effect achieved with a regular LaTeX picture with {0,0} for width and height. Here is a minimal example of what I need the diagram to look like:

\documentclass[a4paper]{report}
\usepackage{tikz}
\begin{document}
\begin{picture}(0,0)(0,0)
  \put(0,3){\vector(1,0){60}}
\end{picture}
Picture
\tikz{\draw [->] (0,0) -- (0:80pt);}
TikZ
\end{document}

This results in the following:

example http://ubuntuone.com/1Kgnezgx4gUSZ9sgJIcjJR

I would like the vector (and the environment in general) of TikZ to be over the word and not displace it. Similar to the one with Picture. I feel there's a straightforward solution for this, but I can't seem to find it.

Thank you

Benedikt Bauer
  • 6,590
  • 2
  • 34
  • 60
Tymric
  • 527
  • 1
  • 3
  • 11

2 Answers2

7

You can use the overlay option:

\tikz[overlay]{\draw [->] (0,0) -- (0:80pt);}

If you want to raise the error the baseline option might help:

\tikz[overlay,baseline=-0.8ex]{\draw [->] (0,0) -- (0:80pt);}

Together with overlay the remember picture option offers some nice features, like drawing at an absolute position of the current page

\tikz[remember picture, overlay]{\draw (current page.center) circle [radius=10mm];}

(where current page has the anchors of a rectangular node) or connecting two pictures

\tikz[remember picture,baseline=(first.base)]{\node [blue] (first) {First Node};}
Some regular Text her in this line.

A new paragraph and more text, ending with a
\tikz[remember picture,baseline=(second.base)]{\node [blue] (second) {second Node};}.

\tikz[remember picture, overlay]{\draw [blue,<->] (first) to[bend left] (second);}

connecting pictures

Tobi
  • 56,353
3
\documentclass[a4paper]{report}
\usepackage{tikz}
\begin{document}
\begin{picture}(0,0)(0,0)
  \put(0,3){\vector(1,0){60}}
\end{picture}
Picture

\makebox(0,0){\put(0,3){\vector(1,0){60}}}
Picture

\makebox[0pt][l]{\tikz\draw [->] (0,0) -- (0:80pt);}
TikZ

\tikz\draw [overlay,->] (0,0) -- (0:80pt);
TikZ
\end{document}