前:
\documentclass{standalone}
\usepackage[alignedleftspaceno]{amsmath}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\path node[fill=black,text=white]
{%
$%
\begin{gathered}
a+b=\text{cvar}\\ % THIS LINE WILL BE CHANGED LATER TO INCLUDE \textcolor
a=\text{cvar}-b % THIS LINE WILL BE CHANGED LATER TO INCLUDE \textcolor
\end{gathered}
$
};
\end{tikzpicture}
\end{document}
后:
a+b=\textcolor{red}{\text{cvar}}\\
a=\textcolor{red}{\text{cvar}}-b
答案1
我想这基本上就是大卫在他最新的评论中所提到的:不要text=white
使用 ,而要使用font=\color{white}
。
\documentclass{standalone}
\usepackage[alignedleftspaceno]{amsmath}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\path node[fill=black,font=\color{white}]
{%
$%
\begin{gathered}
a+b=\textcolor{red}{\text{cvar}}\\
a=\textcolor{red}{\text{cvar}}-b
\end{gathered}
$
};
\end{tikzpicture}
\end{document}
答案2
你实际上并不需要tikz
这个,除非你真的需要这个standalone
类:(empheq
加载mathtools
)可以很容易地获得相同的结果:
\documentclass{article}
\usepackage[alignedleftspaceno]{empheq}%
\usepackage[svgnames]{xcolor}
\newcommand{\myblackbox}[1]{\colorbox{black}{\enspace#1\enspace}}
\newenvironment{myempheq}[2][]{%
\setkeys{EmphEqEnv}{#2}%
\setkeys{EmphEqOpt}{box=\myblackbox,#1}%
\fboxsep=8pt\color{white}\EmphEqMainEnv}%
{\endEmphEqMainEnv}
\begin{document}%
\begin{myempheq}{gather}
a+b=\text{\color{red}cvar}\\ % THIS LINE WILL BE CHANGED LATER TO INCLUDE \textcolor
a=\text{\color{red}cvar}-b % THIS LINE WILL BE CHANGED LATER TO INCLUDE \textcolor
\end{myempheq}
\end{document}