# CircuiTikZ American voltage signs not vertically aligned with unicode-math

I am creating a circuit diagram, and noticed that the voltage signs are not aligned vertically.

I have manually added the red overlay to highlight the issue.

I used XeLaTeX through LaTeXmk, and here is the code:

\documentclass{standalone}

\usepackage{unicode-math}
\setmathfont{Latin Modern Math}

\usepackage{circuitikz}

\begin{document}
\begin{circuitikz}[american]
\ctikzset{voltage=raised}
\draw (0, 0) to[R=$R_1$, *-*, v=$v_1$] ++ (-2, 0);
\end{circuitikz}
\end{document}


If I remove the unicode-math package and Latin Modern Math font, then the issue is fixed. Is it possible to fix this issue within unicode-math?

Thanks for the help!

• Interesting question. I am not sure what happens here, and I have little time to look at it now (I am on vacation!). Could you please try to see how ${}-{}+{}$ renders in the two conditions... Aug 2, 2021 at 8:14
• BTW, reversing the loading order doesn't help. Aug 2, 2021 at 14:34
• It looks to me if the - is not in place when I look at the heigths of the rules in respect to the v. Aug 2, 2021 at 15:40

I found the problem: in the standard LaTeX math font, the minus sign has a box that is the same size of the plus sign, and centered. In the Latin Modern Math, the minus has a box which is asymmetric. Look at this example and test with or without unicode-math and Latin Modern Math...

% TeX program = lualatex
\documentclass{standalone}

\usepackage{unicode-math}
\setmathfont{Latin Modern Math}

\usepackage{circuitikz}

\begin{document}
\begin{tikzpicture}
\ctikzset{voltage=raised}
\draw (0.5,1) node[draw,red,thin,inner sep=1pt]{$-$}
(1,1) node[draw,red,thin,inner sep=1pt]{$+$};
\draw (0, 0) to[R=$R_1$, *-*, v=$v_1$, name=A] ++ (2, 0);
\draw[red, opacity=0.5]  (A-Vfrom) -- (A-Vto);
\ctikzset{voltage/american plus=$+$}
\ctikzset{voltage/american minus=$\vphantom{+}-$}
\draw (0, -2) to[R=$R_1$, *-*, v=$v_1$, name=B] ++ (2, 0);
\draw[red, opacity=0.5]  (B-Vfrom) -- (B-Vto);
\end{tikzpicture}
\end{document}


With unicode-math and the Latin Modern Math:

Without unicode-math (look at the boxes!)

So the problem is that the minus sign is not centered in its box in unicode-math. I do not know if this is a feature or not, but given that circuitikz position the nodes one by one, it confounds it.

The workaround, as you see, is using:

\ctikzset{voltage/american minus=$\vphantom{+}-$}


that fixes the position of the minus sign.

• Thank you very much for the detailed answer! Aug 3, 2021 at 1:18