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 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.

share|improve this question
add comment

1 Answer

up vote 11 down vote accepted

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.

share|improve this answer
add comment

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.