Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is it possible to get a labelname in circuitikz to be equal to the output from

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{circuits.ee.IEC}
\usepackage{siunitx}
\begin{document}
\begin{tikzpicture}[circuit ee IEC,every info/.style={font=\footnotesize},set resistor graphic=var resistor IEC graphic]
    \draw (0,0) to[resistor={info={$R_\text{L}=\SI{220}{\ohm}$}}] (2,0);
\end{tikzpicture}
\end{document}

As far I've understood there's no "info" property in circuitikz, so I can't figure out how to do the same with that package. E.g., using something like

\draw (0,0) to[R=$R_1=\SI{2}{\ohm}$] (2,0)

results in an error in circuitikz.

If possible, I'd prefer to use circuitikz over the circuits.ee.IEC library as I like the symbols in circuitikz more.

Best regards, dm

Edit:

circuitikz example that's not working:

\documentclass{article}
\usepackage{tikz}
\usepackage[siunitx,european,americanresistors]{circuitikz}
\begin{document}
\begin{tikzpicture}[american currents]
    \draw (0,0) to[R=$R_1=\SI{2}{\ohm}$] (2,0);
\end{tikzpicture}
\end{document}
share|improve this question
    
Does it work if you don't use \SI? I've had issues with siunitx and pgfplots, so it could be that it clashes with TikZ. –  qubyte Dec 21 '11 at 12:36
    
No, unfortunately. I get the following error: "! Extra }, or forgotten $.\@let@token ...rc@temp ) {\pgf@circ@finallabel {}}" –  militiaOfDeath Dec 21 '11 at 12:40
    
Your code compiles fine for me (looks nice too). I'm on an up to date TeXLive 2011 though. What are you using? –  qubyte Dec 21 '11 at 12:49
    
You compile fine when you use circuitikz and a command like i.e. \draw (0,0) to[R=$R_1=\SI{2}{\ohm}$] (2,0) ? I use TexLive 2011, which I updated about two weeks ago. But I'll run an update now and see if it works after the update. Edit: tried to compile now after updating, still the same error when using circuitikz. –  militiaOfDeath Dec 21 '11 at 12:52
    
Oh, I'm sorry, I've misread the question! If possible, could you provide a nearly complete example with circuitikz that you'd like modified? –  qubyte Dec 21 '11 at 12:53
show 5 more comments

2 Answers

up vote 3 down vote accepted

Putting the label in a \mbox seems to do the trick. Try the following version:

\documentclass{standalone}
\usepackage{tikz}
\usepackage[siunitx,european,americanresistors]{circuitikz}
\begin{document}
\begin{tikzpicture}[american currents]
    \draw (0,0) to[R,label=\mbox{$R_1=\SI{2}{\ohm}$}] (2,0);
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
1  
Thanks again for your help! –  militiaOfDeath Dec 21 '11 at 13:08
    
You're most welcome! –  qubyte Dec 21 '11 at 13:09
add comment

The problem is that TikZ thinks a = identifies a new option. Like in

(0,0) node[R,l=test=yes]

it is assumed that l=tes and t=yes (or something like this... At least it breaks!)

Inside a math environment, you can escape the "equals" by {=}:

(0,0) to[R,l=$R_g{=}\SI{10}{\ohm}$] ++(2,0);
share|improve this answer
    
Actually, =yes is just discarded. With your solution, the = has wrong spacing. It would be better to do to[R,label=${R_1=\SI{2}{\ohm}}$]. (At the most outer place, it would need eight braces because of how PGFkeys strips one pair away on the way to the actual key that deals with the labeling. I blame circuitikz for not inserting { } again.) –  Qrrbrbirlbel Nov 12 '13 at 16:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.