背景

背景

有沒有辦法在數學模式下保持文字的「粗體」:例如:

\documentclass{standalone}
\newcommand{\mathkeepboldness}[1]{\ensuremath{#1}} % this should keep the text formating
\begin{document} 
\begin{tabular}{l}
    Here \mathkeepboldness{a^b} should not be bold\\
    \textbf{Here: \mathkeepboldness{a^b} should be bold}\\
\end{tabular}
\end{document}

在此輸入影像描述 或者檢測「大膽」也會有所幫助。然後我可以寫一個新命令

\newcommand{\keepbold}[1]    \ifbold {\ensuremath{\mathbf{#1}}} {\ensuremath{#1}}

我希望它能夠在任何 LaTeX 發行版上正常運作。

先致謝

背景

我正在使用 acronym 套件將我的變數映射到它的含義。例如:

\acro{v} [\ensuremath{v}] {velocity}
...

這允許我在文本和方程式中使用縮寫詞:例如:

\ac{v} is defined as:
\begin{equation}
    \ac{v}=\frac{\ac{d}}{\ac{t}}
\end{equation}

我希望這在粗體文字中也能起作用。

答案1

請注意這一點:數學模式中的粗體字母通常有其正確的含義。在某些風格選擇中,粗體也被轉移到數學中,但當然你不能對特定符號使用粗體。

\documentclass{article}
\usepackage{amsmath}

\AddToHook{cmd/bfseries/after}{\boldmath}

\begin{document} 

Here $a^b$ should not be bold

\textbf{Here: $a^b$ should be bold}

\end{document}

在此輸入影像描述

相關內容