无论是否处于数学模式,都处理粗体/文本

无论是否处于数学模式,都处理粗体/文本

acro在一个非常大(1000+页)的文档中使用包。

出于一致性的原因,公式中可能会出现首字母缩略词。

我的杂技设置

\acsetup{
    case-sensitive      = true,
    first-style         = long-short,
    subsequent-style    = long, 
    single-style        = long,
    format/short        = \bfseries,
    format/long         = \bfseries,
    format/first-long   = \bfseries,
    format/foreign      = \itshape,
} 

我尝试处理出现首字母缩略词的情况mathmode

确实,\bfseries选项必然会产生不可用的错误mathmode

\newcommand{\mymmode}{
\ifmmode \bfseries\boldmath \else \bfseries \fi
}

我还尝试确保长缩写词应在数学模式的文本中

\newcommand{\mymmodeText}{
\ifmmode \mbox \else \fi % <- This looks really bad.
}

在此处输入图片描述

M(几乎)WE 因为我遇到了错误。

\documentclass{article}
\usepackage{amsmath}
\usepackage{acro}

\DeclareAcronym{df}{%
    short = {\text{DF}}, 
    long = {facteur d'actualisation}, 
    tag = {abbrev}, 
    foreign = {Discount Factor}, 
    foreign-babel = {french}, 
    foreign-locale = {english}, 
    plural-form = {facteurs d'actualisation}, 
    sort = {discount}, 
}

\newcommand{\mymmode}{
\ifmmode \bfseries\boldmath \else \bfseries \fi
}

\newcommand{\mymmodeText}{
\ifmmode \mbox \else \fi
}


\acsetup{
    case-sensitive      = true,
    first-style             = long-short,
    subsequent-style    = long, 
    single-style        = long,
    format/short        = \mymmode,
    format/long             = \mymmodeText,
    format/first-long   = \mymmodeText,
    format/foreign      = \itshape,
} 


\begin{document}

\begin{align*}
    \ac{df}     & = \dots \\
    \acl{df}        & = \dots \\
    \acs{df}        & = \dots \\
    \aclp{df}   & = \dots \\
    \acsp{df}   & = \dots \\
\end{align*}

\end{document}

相关内容