0

Is there a way to keep the "boldness" of text, in math mode: eg:

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

enter image description here Alternatively to detect the "boldness" would also help. Then I could write a new command

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

I want this ideally to work on any LaTeX distribution.

Thanks in advance

Background

I'm using the acronym package to map my variables to the meaning of it. eg:

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

This allows me to use the acronym in text and equations: eg:

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

And I want this to also work when in bold text.

3
  • 1
    Please always try to show a minimal working example instead of code snippets only. Maybe you want amsmath command \text. But this is only a guess.
    – cabohah
    Apr 15 at 9:49
  • \mathbf makes things upright roman` I guess you are looking for \bfseries\boldmath bold text $ bold math$ Apr 15 at 10:58
  • Note most math publishers do not make math bold in bold regions as unlike text where boldness is just stylistic choice, changing to a bold font can change the meaning, eg make a scalar variable a vector. Apr 15 at 10:59

1 Answer 1

7

Be careful with this: boldface letters in math mode usually have their proper meaning. In some stylistic choices, boldface is also transferred to math, but of course you cannot use boldface for particular symbols.

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

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .