答案1
帮自己一个忙,定义宏:
\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}
不要$$
在 LaTeX 中使用,请参阅为什么 \[ ... \] 比 $$ ... $$ 更可取?
以下是另一种选择:
\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}