中央揃えのアスタリスク (∗) 数学演算子に別のフォントの記号を使用しようとしています。問題のフォントには、(多くのフォントでは) 高さのあるアスタリスク グリフ (*) しかありませんが、私はこれを低くして中央揃えのバリアントとして使用しようとしています。
数式モードでは、演算子は と の両方で使用できます。これら*
は\ast
の 150 行目と 297 行目でまったく同じように定義されていますfontmath.ltx
。
\ast
は で再定義できます\renewcommand
が、*
別の問題のようです。これをマクロに変更したり、その他の方法でグリフのベースラインを変更したりすることはできますか?
\documentclass{minimal}
\DeclareSymbolFont{mymathoperators}{OT1}{phv}{m}{n}
\DeclareMathSymbol{\protoast}{\mathbin}{mymathoperators}{"2A}
\DeclareMathSymbol{*}{\mathbin}{mymathoperators}{"2A}
\renewcommand*{\ast}{\mathbin{\raisebox{-0.7ex}{\ensuremath{\protoast}}}}
\begin{document}
\( good \ast , bad * . \)
\end{document}
答え1
\documentclass{article}
\usepackage{amsmath}
\usepackage{etoolbox}
\DeclareSymbolFont{mymathoperators}{OT1}{phv}{m}{n}
\DeclareMathSymbol{\protoast}{\mathbin}{mymathoperators}{"2A}
\DeclareMathSymbol{*}{\mathbin}{mymathoperators}{"2A}
\renewcommand*{\ast}{\mathbin{\raisebox{-0.7ex}{\ensuremath{\protoast}}}}
\makeatletter
\newcommand{\DeclareMathActive}[2]{%
% #1 is the character, #2 is the definition
\expandafter\edef\csname keep@#1@code\endcsname{\mathchar\the\mathcode`#1 }
\begingroup\lccode`~=`#1\relax
\lowercase{\endgroup\def~}{#2}%
\AtBeginDocument{\mathcode`#1="8000 }%
}
\newcommand{\std}[1]{\csname keep@#1@code\endcsname}
\patchcmd{\newmcodes@}{\mathcode`\-\relax}{\std@minuscode\relax}{}{\ddt}
\AtBeginDocument{\edef\std@minuscode{\the\mathcode`-}}
\makeatother
\DeclareMathActive{*}{\ast}
\begin{document}
\(good \ast , bad * . \)
\end{document}