5

The underset of my "xdim" command is touching characters in the line underneath. How to correct?

\documentclass[12pt]{minimal}
\usepackage{amsmath}

\newcommand{\xdim}[1]{\underset{\textrm{vec}}{\textrm{dim}}\left(#1\right)}

\begin{document}
$\xdim{f}$ consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna al ali qua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\end{document}

enter image description here

1
  • Do you really want to use that notation in inline math? Things like \sum switch automatically to using a subscript position rather underneath when used in inline math for exactly this reason. Commented Sep 11, 2013 at 20:01

2 Answers 2

5

Defining dim as an operator allows for distinguishing between inline and display equations in the "traditional" way: Subscripts are set "on the side" with inline use, while set "underneath" when used inside a display.

enter image description here

\documentclass[12pt]{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath

\newcommand{\xdim}[1]{\underset{\textrm{vec}}{\textrm{dim}}\left(#1\right)}
\DeclareMathOperator*{\DIM}{dim}
\newcommand{\xxdim}[1]{\DIM_{\text{vec}}(#1)}

\begin{document}
$\xdim{f}$ consectetur adipisicing elit, $\xxdim{f}$ sed do 
eiusmod tempor incididunt ut labore et dolore magna al ali qua. 
Ut enim ad minim veniam, quis nostrud exercitation ullamco 
laboris nisi ut aliquip ex ea commodo consequat.
\[
  \xdim{f} \neq \xxdim{f}
\]
\end{document}

For this you require the starred version: \DeclareMathOperator*

2

If you wish to keep the general appearance as you provided in your MWE, with that close line spacing, I see two options, and I have employed them both here. First, I made the underset in \scriptscriptstyle to save on vertical space. Secondly, I used stackengine, rather than \underset, to minimize the undersetting gap, set here to 1pt.

\documentclass[12pt]{minimal}
\usepackage{stackengine}
\usepackage{amsmath}

\newcommand{\xdim}[1]{\stackMath\stackunder[1pt]{%
  \textrm{dim}}{\scriptscriptstyle\textrm{vec}}\left(#1\right)}

\begin{document}

$\xdim{f}$ consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna al ali qua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat.

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .