1

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}\\
&\to\Delta 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}\\
&\to\Delta 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

1
2

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){};} \to\Delta r \leq \frac{r}{n-1}\\
&\to\Delta 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){};}\to\Delta r \leq \frac{r}{n-1}\\
&\to\Delta 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

1
  • I knew about the tikzmark library, but I was hoping for a handmade solution. @Rmano I was about to point out about the white space, but this works perfectly. Thank you. – Luca Benatti Mar 13 at 11:22

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.