使用expl3

使用expl3

数学模式中的字符$\ell$明显倾斜,以匹配数学模式字符的正常倾斜。有没有办法排版一个直立版本,而不会在其他直立数学模式字符中显得倾斜?

答案1

我定义了一个新的控制序列\uell,它排版一个\ell但旋转了 10 度。它还调整了旋转的 周围的间距\ell,使其与未旋转的 相同\ell

\documentclass{article}
\pagestyle{empty}% for cropping
\usepackage{graphicx}
\makeatletter
\DeclareRobustCommand*\uell{\mathpalette\@uell\relax}
\newcommand*\@uell[2]{
  % We need to adjust the width of \uell to be the same as \ell
  \setbox0=\hbox{$#1\ell$}
  \setbox1=\hbox{\rotatebox{10}{$#1\ell$}}
  \dimen0=\wd0 \advance\dimen0 by -\wd1 \divide\dimen0 by 2
  \mathord{\lower 0.1ex \hbox{\kern\dimen0\unhbox1\kern\dimen0}}
}
\begin{document}
\section{$\uell$}
\ttfamily
\begin{tabular}{ll}
  \string\ell  & $jk\ell mn$                  \\
  \string\uell & $jk\uell mn$                 \\
  \string\ell  & $jk\ell_{\ell_{\ell}} mn$    \\
  \string\uell & $jk\uell_{\uell_{\uell}} mn$ \\
\end{tabular}
\end{document}

在此处输入图片描述

使用expl3

当然,输出保持不变。

\documentclass{article}
\pagestyle{empty}% for cropping
%\usepackage{xparse} expl3 is now default since 2020
\ExplSyntaxOn

\box_new:N \l_uell_box
\dim_new:N \l_uell_dim

\cs_new_protected:Npn \__uell:nn #1#2
  {
    % We need to adjust the width of \uell to be the same as \ell
    \hbox_set:Nn \l_uell_box { $#1\ell$ }
    \dim_set:Nn \l_uell_dim { \box_wd:N \l_uell_box }
    \box_rotate:Nn \l_uell_box { 10 }
    \dim_set:Nn \l_uell_dim { (\box_wd:N \l_uell_box - \l_uell_dim) / (-2) }
    \tex_mathord:D {
      \box_move_down:nn { .1ex } {
        \hbox:n {
          \tex_kern:D \l_uell_dim
          \hbox_unpack_drop:N \l_uell_box
          \tex_kern:D \l_uell_dim
        }
      }
    }
  }

\NewDocumentCommand\uell{}
  {
    \mathpalette \__uell:nn \scan_stop:
  }

\ExplSyntaxOff
\begin{document}
\section{$\uell$}
\ttfamily
\begin{tabular}{ll}
  \string\ell  & $jk\ell mn$                  \\
  \string\uell & $jk\uell mn$                 \\
  \string\ell  & $jk\ell_{\ell_{\ell}} mn$    \\
  \string\uell & $jk\uell_{\uell_{\uell}} mn$ \\
\end{tabular}
\end{document}

相关内容