TransWikia.com

Aligning nodes in different tikzpictures

TeX - LaTeX Asked by Luca Benatti on May 11, 2021

It is possible to align the baseline of two nodes in different tikzpictures. I have a tikz in an align environment as in the following example code

begin{align}
&tikz[remember picture]{node(I){};} to Delta r leq frac{r}{n-1}
&toDelta r - frac{r}{n-2} leq 0
end{align}

and another tikz after this as the following one

tikz[overlay,remember picture]{node at(I){$Delta r to frac{r}{n-1}$};}

How can I make the baseline of the two nodes aligned without messing up the alignment in the align environment?

Edit 1: Minimal (not) working example

documentclass[]{beamer}
usepackage[english]{babel}

usepackage{tikz}

begin{document}
begin{frame}
begin{align*}
&tikz[remember picture]{node(I){};} to Delta r leq frac{r}{n-1}
&toDelta r - frac{r}{n-2} leq 0
end{align*}
visible<2->{tikz[overlay, remember picture]{node[anchor=east] at(I.west){$Delta r to frac{r}{n-1}$};}}
end{frame}
end{document}

In this example, the arrows are not aligned both vertically and horizontally.

The desired output:
enter image description here

One Answer

The vertical alignment problem is because your TikZ node, although void, has a size different from zero. The second one can be solved by the base anchors.

Anyway, you should look at the tikzmark library.

documentclass[]{beamer}
usepackage[english]{babel}

usepackage{tikz}

begin{document}
begin{frame}
begin{align*}
&tikz[remember picture]{node[inner sep=0pt, outer sep=0pt](I){};} toDelta r leq frac{r}{n-1}
&toDelta r - frac{r}{n-2} leq 0
end{align*}
visible<2->{tikz[overlay, remember picture]{node[anchor=base east] at(I.base){$Delta r to frac{r}{n-1}$};}}
end{frame}
end{document}

enter image description here

Still is not perfect though --- some extra space is added by tikz. Better using overlay:

documentclass[]{beamer}
usepackage[english]{babel}

usepackage{tikz}

begin{document}
begin{frame}
begin{align*}
&tikz[remember picture, overlay]{node(I){};}toDelta r leq frac{r}{n-1}
&toDelta r - frac{r}{n-2} leq 0
end{align*}
visible<2->{tikz[overlay, remember picture]{node[anchor=base east] at(I.base){$Delta r to frac{r}{n-1}$};}}
end{frame}
end{document}

enter image description here

Correct answer by Rmano on May 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP