Is there a "best" way to define an underlined math operator? Right now, I've defined
DeclareMathOperator{\uHom}{\underline{Hom}}
This works, sort of, but the underline is too long---it tends to merge with subscripts, e.g. $\uHom_R$
:
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityHere's a slightly different version: I apply the shortening on both sides, for symmetry.
The shorthening depends on the value given to the parameter \uHomskip
.
\documentclass{article}
\usepackage{amsmath}
\newmuskip\uHomskip
\DeclareMathOperator{\uHom}{%
\mkern\uHomskip
\underline{\mkern-\uHomskip Hom\mkern-\uHomskip}
\mkern\uHomskip
}
\begin{document}
\newcommand{\test}[1]{%
\begingroup\uHomskip=#1mu\relax
\makebox[2em][l]{#1:}$\uHom_R$
\endgroup\par
}
\test{0} \test{0.5} \test{1} \test{1.5} \test{2}
\end{document}
When you decide for the amount you want, just set it in the preamble, for instance
\newmuskip\uHomskip \setlength{\uHomskip}{1.5mu}
\DeclareMathOperator{\uHom}{%
\mkern\uHomskip
\underline{\mkern-\uHomskip Hom\mkern-\uHomskip}
\mkern\uHomskip
}
The advantage of using mu
units is that they automatically scale in subscripts/superscripts.
If you don't want the shortening at the left, just remove the relevant kerns:
\newmuskip\uHomskip \setlength{\uHomskip}{1.5mu}
\DeclareMathOperator{\uHom}{%
\underline{Hom\mkern-\uHomskip}
\mkern\uHomskip
}
\mkern
or \mskip
.
You can add/remove small spaces before and in the underlined material.
\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator{\uHom}{\,\underline{\!Hom\!}\,}
\begin{document}
$\uHom_R$
\end{document}
this answer is much like steven's, but is a little more reserved about the sizes of the "small spaces".
\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator{\uHom}{\underline{Hom\kern-.05em}\kern.1em}
\begin{document}
$\uHom_R$
\end{document}
\Hom
isn't already defined (although \hom
is, by amsopn
, i defined it anew, and mu
units were rejected with my first try. possibly a different problem, but i didn't pursue the matter. i like your symmetry better anyhow.
Jan 30, 2017 at 14:08
\hom
is a command in amsmath, right? 2) I fail to see how this question differs from the one at tex.stackexchange.com/q/49324/34551 : can't your find your answer there?