3

I would like to typeset almost all of a formula in bold sans-serif font using \boldsymbol and \mathsf. For example:

$$\boldsymbol{\mathsf{x+{}}}n\boldsymbol{\mathsf{{}=y}}$$

or

$$\boldsymbol{\mathsf{S}}^n\boldsymbol{\mathsf{0}}$$

Output

However, I would like to be able to do it more simply, by enclosing that parts that should be typeset normally in some sort of command. Like this:

$$\boldsymbol{\mathsf{x+\something{n}=y}}$$

Is there a way to do that?

3

Do yourself a favor and define macros:

\documentclass{article}
\usepackage{amsmath}
\usepackage{bm}

\newcommand{\svar}[1]{\bm{\mathsf{#1}}} % syntactic variable
\newcommand{\sfun}[1]{\bm{\mathsf{#1}}} % syntactic function

\begin{document}

Some text before the formula
\[
\svar{x}+n=\svar{y}
\]
and some text in between
\[
\sfun{S}^{n}\svar{0}
\]

\end{document}

enter image description here

Don't use $$ in LaTeX, see Why is \[ ... \] preferable to $$ ... $$?

Here is an alternative:

\documentclass{article}
\usepackage{amsmath}
\usepackage{bm}

\newcommand{\lf}[1]{\bm{#1}}
\newcommand{\var}[1]{\mathsf{#1}}
\newcommand{\meta}[1]{{\mathpalette\dometa{#1}}}
\newcommand{\dometa}[2]{\mbox{\mathversion{normal}$#1#2$}}

\begin{document}

Some text before the formula
\[
\lf{ \var{x}+\meta{n}=\var{y} }
\]
and some text in between
\[
\lf{ \var{S}^{\meta{n}}\var{0} }
\]

\end{document}

enter image description here

4
  • Of course. But I would like to be able to write $\svar{x+\something{n}=y}$. Note that the + and = signs should also be bold. – Gabriel Nivasch Aug 7 '16 at 12:42
  • 2
    @GabrielNivasch Why should you? – egreg Aug 7 '16 at 12:44
  • Because I want very long formulas all written in bold sans-serif with some regular-font elements sprinkled in – Gabriel Nivasch Aug 7 '16 at 12:45
  • 1
    @egreg - De gustibus non est... – Mico Aug 7 '16 at 13:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.