背景

背景

数式モードでテキストの「太字」を維持する方法はありますか: 例:

\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 ディストリビューションでもこれが動作するようにしたいと考えています。

前もって感謝します

背景

私は頭字語パッケージを使用して、変数をその意味にマッピングしています。例:

\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}

ここに画像の説明を入力してください

関連情報