如何垂直移动= 符号?

如何垂直移动= 符号?

我想定义一个命令,打印=标志,其下线接触基线,直接位于基线上,有什么建议吗?

答案1

数学轴是等号两条线的对称轴。如果符号的高度已知且正确,那么我们就知道较高线的顶部和较低线的底部。线条粗细未知。但我们可以计算将符号向下移动到基线所需的移位量:

\documentclass{article}

\makeatletter
\@ifdefinable{\baselineeq}{%
  \DeclareRobustCommand*{\baselineeq}{%
    \ensuremath{% allow invoking \baselineeq in text mode
      \mathrel{%
        % \mathpalette is a LaTeX wrapper for `\mathchoice`.
        % \baseline@eq will get the math style as first argument.
        % the second argument is unused.
        \mathpalette\baseline@eq{}%
      }%
    }%  
  }
  \newcommand*{\baseline@eq}[2]{%
    % #1: math style,
    %     one of\displaystyle, \textstyle, \scriptstyle, \scriptscriptstyle
    % #2: unused
    %
    % * \vcenter centers stuff vertically around the math axis. By putting
    %   an empty `\vcenter{}` in a box, we get the height of the math axis
    %   as height of the box.
    % * Box register 0 is a local scratch register;
    %   we are inside the groups of \mathrel and \mathpalette.
    \sbox0{$#1\vcenter{}$}%
    % * \height inside \raisebox: height of the unraised box
    %   containing the equal sign.
    % * \ht0: height of box 0, thus height of math axis.
    % * Then the netto height of the equal sign is 2*(\height-\ht0).
    %   In \raisebox we lower the equal sign right below the base line
    %   and raise by the netto height.
    % * \m@th resets \mathsurround to 0pt (avoids additional
    %   surrounding space if \mathsurround is set).
    \raisebox{\dimexpr\height-2\ht0\relax}{$\m@th#1=$}%
  }%
}

\begin{document}

\parbox{20mm}{\hrulefill\baselineeq\hrulefill}

$\_\baselineeq\_^{\_\baselineeq\_^{\_\baselineeq\_}}$

\end{document}

结果

评论:

  • 符号宏\baselineeq可以在文本或数学模式下使用。
  • 在数学模式下,该符号是与等号一样的关系符号,但可以通过替换来更改\mathrel
  • \mathpalette用于获取当前的数学风格,它成为 的第一个参数\baseline@eq

答案2

您可以降低角色,也可以使用规则:

在此处输入图片描述

\documentclass{article}
\setlength\textwidth{4cm}
\begin{document}

aaa\hrulefill
$=$\hrulefill
$\mathrel{\raisebox{-.3ex}{$=$}}$\hrulefill
$\mathrel{\vbox{\hrule width .5em height .5pt\vskip .3ex \hrule height .5pt}}$\hrulefill
aaa\hrulefill


\end{document}

相关内容