3

I use an edited version of the \\uline command from the ulem package to get a nice compact double underline to denote tensor variables. The used code comes from this question. My problem is that the macro leaves a very large space below any line with a tensor. I would like this vertical space to be the same as for a simply underlined letter, or even the same as for a standard letter without underlines. How would I do that?

Full example:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage[normalem]{ulem}
\makeatletter
\renewcommand*{\uuline}{%
  \bgroup
  \UL@setULdepth
  \markoverwith{%
    \lower\ULdepth\hbox{%
      \kern-.03em%
      \vtop{%
        \hrule width.2em%
        \kern 0.6pt % distance between the two underlines
        \hrule
      }%
      \kern-.03em%
    }%
  }%
  \ULon
}
\makeatother
\setlength{\ULdepth}{1pt}  % distance from double underline to letter
\newcommand{\mat}[1]{\uuline{#1}{}}

\begin{document}
This is some text with $\mat A$ in it. The problem is that the next line of
text leaves a very big vertical space. The same problem occurs in displayed
maths:

\begin{align*}
A & = B \\
\mat A & = \mat B \\
A & = B
\end{align*}

\end{document}

Robert
  • 163

3 Answers3

2

You can \smash the underline, i.e., set the height and the depth of the box around the underlined letter to 0.

Code:

\newcommand{\mat}[1]{\smash{\uuline{#1}{}}}

Result:

enter image description here

Marijn
  • 37,699
1

I wouldn't use ulem for this, but use \underline, with some tricks for decreasing the clearance between the two lines. This does not completely eliminate the risk of getting more interline space, but should reduce it to the minimum.

To be honest, I would not use double underlining at all; the modern conventions used in technical fields say that tensors should be denoted by slanted sans serif letters.

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newcommand{\mat}[1]{{\mathpalette\mat@{#1}}}
\newcommand{\mat@}[2]{%
  \begingroup
  \sbox\z@{$\m@th#1\underline{#2}$}%
  \dimen@=\dp\z@ \advance\dimen@ -2\mat@dimen{#1}%
  \dp\z@=\dimen@
  \sbox\z@{$\m@th\underline{\box\z@}$}%
  \box\z@
  \endgroup
}
\newcommand\mat@dimen[1]{%
  \fontdimen8
  \ifx#1\displaystyle\textfont\else
  \ifx#1\textstyle\textfont\else
  \ifx#1\scriptstyle\scriptfont\else
  \scriptscriptfont\fi\fi\fi 3
}
\makeatother

\begin{document}
This is some text with $\mat{A}$ in it. The problem is that the next line of
text leaves a very big vertical space. The same problem occurs in displayed
maths:
\begin{align*}
A & = B \\
\mat{A} & = \mat{B} + x_{\mat{C}}\\
A & = B + \mat{C}
\end{align*}

\end{document}

enter image description here

egreg
  • 1,121,712
0

Try this:

\raisebox{-0.5mm}{\underline{\raisebox{0.5mm}[1mm][1mm]{\underline{$\dfrac{1}{2}$}}}}