2

My question is about tikz, as below, I want to add a label "reliability factor" for a term ($z_{\frac{\alpha}{2}}$) inside a math environment. But it create too much space in front and behind that term. How can I reduce the space?

Thanks

CI= $\bar{X}- \tikz[baseline=-1.2pt]{\node(A406)[node distance=1cm,pin={[pin edge={red, dashed,<->},align=left,font=\tiny]90: reliability\\factor}]{$z_{\frac{\alpha}{2}}$};} \frac{\sigma}{\sqrt{n}} < \mu < \bar{X}+z_{\frac{\alpha}{2}} \frac{\sigma}{\sqrt{n}} $ 
1
  • Welcome to TeX.SX! Please, make the snippet a full (short) example from \documentclass to \end{document}. Commented Jun 15, 2017 at 13:34

2 Answers 2

1

You can put the \tikz part in a box with the width of just the actual node content, such that the actual width of the tikz part is ignored. For that, you can e.g. use the command defined in this answer:

\documentclass{article} \usepackage{amsmath} \usepackage{tikz} \newlength\stextwidth \newcommand\makesamewidth[3][c]{% \settowidth{\stextwidth}{#2}% \makebox[\stextwidth][#1]{#3}% } \begin{document} CI= $\bar{X}-\makesamewidth{$z_{\frac{\alpha}{2}}$}{\tikz[baseline=-1.2pt]{\node(A406)[node distance=1cm,pin={[pin edge={red, dashed,<->},align=left,font=\tiny]90: reliability\\factor}]{$z_{\frac{\alpha}{2}}$};}} \frac{\sigma}{\sqrt{n}} < \mu < \bar{X}+z_{\frac{\alpha}{2}} \frac{\sigma}{\sqrt{n}} $ \end{document} 

enter image description here

3

It is better, IMO, to annotate above math rather than include annotations as part of math. To this end, the tikzmark library can be used to mark some points to refer to them later when making your drawings.

\documentclass[12pt,a4paper]{article} \usepackage{amsmath} \usepackage{tikz} \usetikzlibrary{tikzmark} \begin{document} $\text{CI} = \bar{X}- z\tikzmark{p}_{\frac{\alpha}{2}} \frac{\sigma}{\sqrt{n}} < \mu < \bar{X}+z_{\frac{\alpha}{2}} \frac{\sigma}{\sqrt{n}} $ \tikz[overlay,remember picture]{% \draw[<->,dashed,red]([yshift=10pt]pic cs:p)--++(0,3ex)node[align=center,font=\tiny,black,above]{reliability\\ factor}; } \end{document} 

enter image description here

If you still prefer your syntax, you can simply add \makebox[0pt]{<the picture>} and pull the math out of the node contents.

$\text{CI} =\bar{X}- z\makebox[0pt]{\tikz{\node(A406)[pin={[pin edge={red, dashed,<->},align=center,font=\tiny]90: reliability\\factor}]{};}} _{\frac{\alpha}{2}}\frac{\sigma}{\sqrt{n}} < \mu < \bar{X}+z_{\frac{\alpha}{2}} \frac{\sigma}{\sqrt{n}} $ 

The same result is obtained as above.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.