# Horizontally misaligned labels in xy package

I have answered to a this question, Long arrows in a commutative diagram with transform canvas with this MWE:

\documentclass[a4paper,12pt]{article}
\usepackage[cmtip,all]{xy}
\labelmargin-{1pt}
\begin{document}
\xymatrix@R=1.5cm@C=2cm{
A \ar@<.5ex>[r]^{f} \ar@<.5ex>[d]^{g}& \ar@<.5ex>[l]^{h} B\ar@<.5ex>[dl]\\
C \ar@<.5ex>[u]^{r} \ar@<.5ex>[ur] &
}
\end{document}


Why are r and g labels not well aligned horizontally, like vertical labels?

• do you mean horizontally or vertically? your orange line is drawn at a strange place, below the baseline, if you draw the baseline it looks natural to me rg you expect the tail of the g to be below the r surely? Jun 2 '20 at 18:51
• @DavidCarlisle Very kind David Before I have used the translator. Yes you're right: I expect the tail of the g to be below the r. If you want to change my unclear question you're welcome always or welcome. Jun 2 '20 at 18:55
• To align the r and g, I would enter the r as {r\vphantom{g}} to raise the r. Although the depth of the g could be removed by \smash[b]{g}, that would move it lower, and it already looks closer to the bottom than to the top. (Not tested.) Jun 2 '20 at 19:51

As from the suggestion of the very nice user @barbara beeton, I have added your solutions (by your comment):

1. using \phantom:

\documentclass[a4paper,12pt]{article}
\usepackage[cmtip,all]{xy}
\labelmargin-{1pt}
\begin{document}
\xymatrix@R=1.5cm@C=2cm{
A \ar@<.5ex>[r]^{f} \ar@<.5ex>[d]^{g}& \ar@<.5ex>[l]^{h} B\ar@<.5ex>[dl]\\
C \ar@<.5ex>[u]^{r\vphantom{g}} \ar@<.5ex>[ur] &
}
\end{document}


2. or using \smash[b]{g}

\documentclass[a4paper,12pt]{article}
\usepackage{mathtools}

\usepackage[cmtip,all]{xy}
\labelmargin-{1pt}
\begin{document}
\xymatrix@R=1.5cm@C=2cm{
A \ar@<.5ex>[r]^{f} \ar@<.5ex>[d]^{\smash[b]{g}}& \ar@<.5ex>[l]^{h} B\ar@<.5ex>[dl]\\
C \ar@<.5ex>[u]^{r} \ar@<.5ex>[ur] &
}
\end{document}