A thing I'd often like to do is put in my document a box the size of some text A and containing some other text B. For instance, I have two tikz
nodes, one containing $n$ and one containing $n+1$, and I want them to be the same size (but not larger than necessary, as I would get by specifying a minimum width
).
If I want the text B to be right- or left-aligned, I can do the trick with a combination of phantom
and mathrlap
/mathllap
. However, if I want it to be centered, I don't see an easy way to do it.
Is there a simple command in some package to do this? It looks like a common task.
Minimal example: I want to alter the bounding box of $n$ so that the two circles are the same size (and $n$ is still centered in the circle).
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node[circle,draw=black] (A) {$n$};
\node[circle,draw=black] (B) [right of=A] {$n+1$};
\end{tikzpicture}
\end{document}