我使用\\uline
来自ulem
来获得一个漂亮的紧凑双下划线来表示张量变量。所用代码来自这个问题。我的问题是宏在任何带有张量的线下方留下了一个非常大的空间。我希望这个垂直空间与简单下划线字母的垂直空间相同,甚至与没有下划线的标准字母的垂直空间相同。我该怎么做?
完整示例:
\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}
答案1
答案2
我不会ulem
为此使用,而是使用\underline
,并采用一些技巧来减少两行之间的间隙。这并不能完全消除获得更多行间空间的风险,但应该可以将其降至最低。
说实话,我会不是完全不使用双下划线;技术领域使用的现代惯例规定张量应该用倾斜的无衬线字母表示。
\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}
答案3
尝试这个:
\raisebox{-0.5mm}{\underline{\raisebox{0.5mm}[1mm][1mm]{\underline{$\dfrac{1}{2}$}}}}