14

I use the following code to draw a tikz image between some text:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{
calc
}

\begin{document}
Hello\tikz[baseline=(current bounding box.north)]\draw(0,0) circle (10pt);\LaTeX.
\end{document}

Then I want to add a little shift to it, for example

\tikz[baseline=(current bounding box.north)-5pt]\draw(0,0) circle (10pt);

But this have no effect. I also tried yshift or transform canvas, both does not work.

Does anyone know how to solve this? thanks.

1 Answer 1

20

You can add the shift by one of the following ways. Only the last one needs the calc library. In both cases you need to surround the coordinate with { } to either mask the inner [ ] or ,.

Hello\tikz[baseline={([yshift=-5pt]current bounding box.north)}]\draw(0,0) circle (10pt);\LaTeX.

Hello\tikz[baseline={($ (current bounding box.north) - (0,5pt) $)}]\draw(0,0) circle (10pt);\LaTeX.

Note that the ([<options>]coordinate) style works also in general (so does the other one). If you want to shift from the center of a node you should explicitly reference the center anchor to avoid some possible issues. Without an anchor the special border anchor is used which seems to cause issues with shifts. With baseline there might be no problem, but for drawn lines there is.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .