# Defining a unit with \DeclareSIUnit causes siunitx to throw an error

I am trting to define a custom unit as follows

\DeclareSIUnit{\cmHg}{\centi\meter.\mathrm{Hg}}


In previous versions of siunitx, it was working very well. With the newest version it does not. Even the dot does not appear.

My MWE

\documentclass[aspectratio=169, xcolor={x11names}, t, handout]{beamer}

\usetheme{Dresden}
\usefonttheme{professionalfonts}

\usepackage{siunitx}
\DeclareSIUnit{\cmHg}{\centi\meter.\mathrm{Hg}}

\begin{document}

\begin{frame}

$\si{\cmHg}$

$\si{\centi\meter.\mathrm{Hg}}$

\end{frame}

\end{document}


Intermixing 'literal' and macro-based units has always been somewhat risky. In v3, a more controlled code path means that you do need to separate them out cleanly. As cmHg is a unit in it's own right, I would simply use
\DeclareSIUnit{\cmHg}{cmHg}

\DeclareSIUnit[qualifier-mode = space]{\cmHg}{\centi\metre\of{Hg}}

• Thanks for the answer. However, books usually provide the unit as cm.Hg (with a dot at the baseline). The dot still causes an error and even does not show up when typing \si{\centi\meter.\mathrm{Hg}} Sep 23 at 17:17
• A dot in a literal unit has always meant a space: that goes back to the syntax inherited from SIstyle over a decade ago! Sep 23 at 17:35