答案1
我仍然认为下划线是邪恶的,而且是非常过时的符号。
无论如何,这是一个可行的解决方案。
\documentclass{article}
\usepackage{amsmath}
\makeatletter
% overline
\newcommand{\dbloverline}[1]{\overline{\dbl@overline{#1}}}
\newcommand{\dbl@overline}[1]{\mathpalette\dbl@@overline{#1}}
\newcommand{\dbl@@overline}[2]{%
\begingroup
\sbox\z@{$\m@th#1\overline{#2}$}%
\ht\z@=\dimexpr\ht\z@-2\dbl@adjust{#1}\relax
\box\z@
\ifx#1\scriptstyle\kern-\scriptspace\else
\ifx#1\scriptscriptstyle\kern-\scriptspace\fi\fi
\endgroup
}
% underline
\newcommand{\dblunderline}[1]{\@@underline{\dbl@underline{#1}}}
\newcommand{\dbl@underline}[1]{\mathpalette\dbl@@underline{#1}}
\newcommand{\dbl@@underline}[2]{%
\begingroup
\sbox\z@{$\m@th#1\@@underline{#2}$}%
\dp\z@=\dimexpr\dp\z@-2\dbl@adjust{#1}\relax
\box\z@
\ifx#1\scriptstyle\kern-\scriptspace\else
\ifx#1\scriptscriptstyle\kern-\scriptspace\fi\fi
\endgroup
}
\newcommand{\dbl@adjust}[1]{%
\fontdimen8
\ifx#1\displaystyle\textfont\else
\ifx#1\textstyle\textfont\else
\ifx#1\scriptstyle\scriptfont\else
\scriptscriptfont\fi\fi\fi 3
}
\makeatother
% vectors and matrices
\renewcommand{\vec}[1]{{%
\mspace{0.5mu}%
\underline{\mspace{-0.5mu}#1_{}\kern-\scriptspace\mspace{-0.5mu}}%
\mspace{0.5mu}%
\mathcorr{#1}%
}}
\newcommand{\mat}[1]{{%
\mspace{0.5mu}%
\dblunderline{\mspace{-0.5mu}#1_{}\kern-\scriptspace\mspace{-0.5mu}}%
\mspace{0.5mu}%
\mathcorr{#1}%
}}
\makeatletter
\newcommand{\mathcorr}[1]{\mathpalette\math@corr{#1}}
\newcommand{\math@corr}[2]{%
\begingroup
\sbox\z@{$\m@th#1#2$}\sbox2{$\m@th#1#2_{}\kern-\scriptspace$}%
\kern\dimexpr\wd\z@-\wd\tw@\relax
\endgroup
}
\makeatother
\begin{document}
\begin{gather*}
\mat{X}\mat{X}\mat{Y}^2
\\
\vec{X}\vec{X}\vec{f}
\\
F(\vec{v})
\\
3\vec{\mathrm{i}}+2\vec{\mathrm{j}}-\vec{\mathrm{k}}
\end{gather*}
\end{document}
这个想法是
- 删除字母后插入的斜体更正
- 在字母的较小部分下划线
- 在周围添加相同的空格
- 恢复斜体修正
- 使用更紧凑的双下划线版本
代码片段来自