artisticat1 / obsidian-tikzjax

Render LaTeX and TikZ diagrams in your notes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

need `siunitx` or `\pu` support for drawing circuits

shs-cse opened this issue · comments

Can't use siunitx package for using SI units with circuitikz. Obsidian supports \pu command for physical units natively. But that doesn't work either.

For now, I am using this macro to get around the issue:

\def\u#1{\ua{#1}#1\end O\end\eend}
\def\ua#1#2O\end#3\eend{%
	\ifx\end#3%
	\end\ensuremath{\textrm{#1}}%
	\else\ensuremath{\textrm{#2}\Omega}%
	\fi%
}

How to use: \u{1 kO}. This should be rendered as: $\textrm{1 k}\Omega$

This will create issues with micro($\mu$) units tho.

I wanted to draw a circuit and write on the labels of my resistors the ohm value, but there is no support for siunitx

\usepackage{circuitikz}
\usepackage{siunitx}
\begin{document}
\begin{circuitikz}\draw
    (0,0) to [battery] (0,3)
    (0,3) to [R=2\si{\ohm}, l_=$2\ohm$] (3,3)
    (3,3) to [R=3\si{\ohm}, l_=$R_2$] (3,0)
    (3,0) to [R=5\si{\ohm}, l_=$R_3$] (0,0)
;
\end{circuitikz}
\end{document}