自动强调字体

自动强调字体

我想要使​​用字体书写缩写\mathsf。为此,我创建了一个命令\mystyle。我希望这些缩写在强调环境中自动被强调。有办法实现吗?

下面的 MWE 中提出的简单方法不起作用。

\documentclass{article}
\newcommand{\mystyle}[1]{$\mathsf{#1}$}

\begin{document}
    If I write outside of an environment, all is fine, and \mystyle{ABC} is typeset the way it should

    \emph{If I am in an emphasized environment, I want \mystyle{ABC} to be emphasized as well}
\end{document}

答案1

您需要的是文本字体,而不是数学。

在此处输入图片描述

\documentclass{article}
\newcommand{\mystyle}[1]{\textsf{#1}}

\begin{document}
    If I write outside of an environment, all is fine, and \mystyle{ABC} is typeset the way it should

    \emph{If I am in an emphasized environment, I want \mystyle{ABC} to be emphasized as well}
\end{document}

相关内容