I just learned that you can use braces to scope the effect of \tikzset
. But it is not allowed in align environments:
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\begin{document}
\begin{align}
\tikzset{every node/.style={draw}}
\tikz{\node {};} &= \text{Box}\\
{
\tikzset{every node/.style={fill}}
\tikz{\node {};} &= \text{Filled box}\\
}
\tikz{\node {};} &= \text{Box}\\
\tikz{\node {};} &= \text{Box}
\end{align}
\end{document}
This fails with a lot of errors like "Misplaced alignment tab character" and others.
Sadly, even a workaround doesn't work here:
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\begin{document}
\begin{align}
\tikzset{every node/.style={draw}}
\tikz{\node {};} &= \text{Box}\\
\tikzset{every node/.style={fill}}
\tikz{\node {};} &= \text{Filled box}\\
\tikzset{every node/.style={draw}}
\tikz{\node {};} &= \text{Box}\\
\tikz{\node {};} &= \text{Box}
\end{align}
\end{document}
Notice how the last node is not drawn. What's going wrong?