# Accurately right-aligning text of wildly varying font sizes [duplicate]

I'm trying to right-align pieces of text in separate TikZ nodes. One piece of text is alphabetical and the other is numerical. The numerical text is much larger than the alphabetical text, and I'm finding there is extraneous space to the right of it. As a result, the right alignment is not accurate enough.

Here is a MWE:

% !TEX program = xelatex

\documentclass{book}

\usepackage{tikz}
\usepackage{tikzpagenodes}
\usetikzlibrary{positioning}
\usepackage{fontspec}
\setmainfont{Cambria}

\newcommand\hugefont{
\fontsize{200}{220}\selectfont%
}

\newcommand\smallfont{
\fontsize{20}{22}\selectfont%
}

\begin{document}
\begin{tikzpicture}[remember picture,overlay]%
\node(small) [anchor=north east,fill=green,inner sep=0pt]             at (current page text area.north east) {\smallfont abc};%
\node(big)   [anchor=north east,fill=red,inner sep=0pt,yshift=-10pt]  at (small.south east)                  {\hugefont 123};%
\node(big2)  [anchor=north east,fill=blue,inner sep=0pt,yshift=-10pt] at (big.south east)                    {\hugefont abc};%
\end{tikzpicture}
\end{document}


And here is the result:

As you can see, the "123" has a large gap to the right of the "3", so it doesn't align well. The large "abc" is better, though still imperfect.

I'm aware that my font choice of Cambria exacerbates the issue, but even without it the problem persists to a lesser extent.

Is there any way I can accurately right-align this text without resorting to manual xshift values?

## marked as duplicate by Skillmon, TonioElGringo, Stefan Pinnow, Sebastiano, Steven B. SegletesMar 2 '18 at 10:58

• note your \hugefont and \smallfont commands have % in the wrong place so they will add spurious white space you need {% – David Carlisle Mar 2 '18 at 10:23