2

I'm currently trying to realize an annotation on a TikZ plot, where I point out a limiting value (see picture below). Limiting value

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
    \draw [stealth-,thin] (0,0.9)-- +(16pt,0pt) node[right,font=\footnotesize] 
            {Limiting value: $\lim\limits_{x\rightarrow 0}\omega=0$};
\end{tikzpicture}
\end{document}

The problem that I have is that when I draw a line that connects to the node, my west anchor is not neatly centered to the text, but to the entire node.

Question: How can I get the alignement of my anchor in such a way that the arrow is nicely centered to the text rather than to the entire node?

  • While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. This is especially important for tikz as there are numerous libraries. – Peter Grill Nov 16 '16 at 9:34
  • @PeterGrill Alright, I will remember this, thanks for the tip! The reason I did not do this was because the fact that I did not use any packages, but still it's better to give a complete question. So consider the question edited. – Nick Nov 16 '16 at 10:00
2

One way is to use \smash on the text which you don't want to affect the plcement of the node. Alternatively, you could place the node in two steps:

enter image description here

Code:

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
    \draw [stealth-,thin] (0,0.9)-- +(16pt,0pt) node[right,font=\footnotesize] 
            {Limiting value: \smash{$\lim\limits_{x\rightarrow 0}\omega=0$}};
\end{tikzpicture}

\medskip
\begin{tikzpicture}
    \draw [stealth-,thin] (0,0.9)-- +(16pt,0pt) node[right,font=\footnotesize] (A) {Limiting value:};
    \node [anchor=west,font=\footnotesize, inner sep=0pt] at (A.east) {$\lim\limits_{x\rightarrow 0}\omega=0$};
\end{tikzpicture}
\end{document}
  • Thanks, that completely solved it! :-) What does smash do exactly ? – Nick Nov 16 '16 at 9:58
  • \smash makes TeX think that the content in it takes up no vertical space. A good illustration is at Which package defines \smash?. If it is still not clear you should post a new question. – Peter Grill Nov 16 '16 at 10:09
  • That was all I needed to hear :). Perfect! – Nick Nov 16 '16 at 10:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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