artisticat1 / obsidian-tikzjax

Render LaTeX and TikZ diagrams in your notes
MIT License
356 stars 18 forks source link

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

Open shs-cse opened 1 year ago

shs-cse commented 1 year ago

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.

shs-cse commented 1 year ago

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.

Guilhermwn commented 3 months ago

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}