我想将包含数学符号的文本高度设为灰色,并允许换行。基于这很好的帖子,我试过:
\documentclass{article}
\usepackage{xcolor}
\usepackage{soul}
\newcommand{\mathcolorbox}[2]{\colorbox{#1}{$\displaystyle #2$}}
\newcommand{\hlfancy}[2]{\sethlcolor{#1}\hl{#2}}
\begin{document}
This works: \hlfancy{gray}{colored $a=b$ math}.
This does not: \hlfancy{gray!60}{colored $a=b$ math}.
\end{document}
答案1
这是一个解决方案:
\documentclass{article}
\usepackage[svgnames]{xcolor}
\usepackage{soul}
\newcommand{\mathcolorbox}[2]{\colorbox{#1}{$\displaystyle #2$}}
\newcommand{\hlfancy}[2]{\colorlet{hlcolor}{#1}\sethlcolor{hlcolor}\hl{#2}}
\begin{document}
This works: \hlfancy{gray}{colored $a=b$ math}.
This also works: \hlfancy{gray!30!Lavender}{colored $a=b$ math}.
\end{document}