My last update to circuitikz popped up a strange thing that drove me crazy: if you look at page 78 of the manual for 1.6.7, you can see that the voltage source sign does not follow the color of the component. The strange thing is that they do it on my local build... so I was chasing strange bugs(which can be still there...) until I remembered that the CI scripts that build the release manual are using xelatex (for some historical reason, I think).
To check the problem, I managed to reduce the behavior to this MWE (which generates a couple of files and a script to obtain the final screenshot, if you are on a bash-compatible shell):
\begin{filecontents}{do_color_vam.sh}
pdflatex color-vam && mv color-vam.pdf color-vam-p.pdf
lualatex color-vam && mv color-vam.pdf color-vam-l.pdf
xelatex color-vam && mv color-vam.pdf color-vam-x.pdf
pdflatex color-vam-join
\end{filecontents}
\begin{filecontents}{color-vam-join.tex}
\documentclass[varwidth]{standalone}
\usepackage{graphics}
\begin{document}
\includegraphics{color-vam-p}\par
\includegraphics{color-vam-l}\par
\includegraphics{color-vam-x}\par
\end{document}
\end{filecontents}
\documentclass[border=10pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usepackage{iftex}
\edef\engine{% just for the three cases tested...
\ifluatex LuaLaTeX\else\ifxetex XeTeX \else pdfLaTeX\fi\fi
}
\makeatletter
\pgfdeclareshape{foo}{
\anchor{center}{\pgfpointorigin}%
\behindbackgroundpath{%
\pgfscope
\pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{0.4cm}}{\pgfpoint{0.4cm}{0}}
\pgfusepath{draw}
%\ifxetex
% \pgftext[]{\let\current@color\pgf@fillcolor@global\set@color$+$}
%\else
\pgftext[]{$+$}
%\fi
\endpgfscope
}
}
\makeatother
\begin{document}
\begin{tikzpicture}
\draw[color=red, thick] node[foo]{} ++(1,0)
node[foo, fill=blue]{} ++(1,0)
node[right, text width=3cm]{\engine};
\end{tikzpicture}
\end{document}
If you run it once (with whichever engine, say pdflatex) and then run (on the shell)
sh ./do_color_vam
The file color-vam-join.pdf will look as follows:
As you can see, xelatex has a different behavior. Notice that the fact that the first two "plus" signs are blue is normal because \pgftext uses the fill color to render the text (it also is normal that the circles are not filled up because I explicitly used only draw in the \pgftext command).
Ulrike Fischer (thanks!) suggested in the comments a possible solution, which I added (commented out) to the MWE: if you remove the comments and rerun, you will have:
which is arguably better for the default case, but as Ulrike herself noticed, it does not make the behavior the same for the three engines.
Is there some trick to make xelatex behave like the other two engines?


\pgftext[]{\ifxetex\let\current@color\pgf@fillcolor@global\set@color\fi $+$}would work in your example, but break again if you use a color on your nodenode[fill=green,foo]{}. You are probably on another round of "figure out the color settings" https://tex.stackexchange.com/a/635242/2388 – Ulrike Fischer Feb 11 '24 at 10:33\ifxetexwith some of the state I am trying to store after dealing with the other question you pointed to. Thanks! – Rmano Feb 11 '24 at 11:36text=blueas option (plus the\ifxetexstuff). But I wonder why that is ... – Jasper Habicht Feb 16 '24 at 09:04