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.

I need to draw a zig-zag line inside a circle without using decorations. The size and positioning of the line should be relative to the size of the circle. I used this code:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}

\node[draw,circle,minimum size=1cm] (C) at (0,0){};

\draw    ($($ (C.west)!.1!(C.east) $)-(0,30pt)$)  --($ (C.west)!.1!(C.east) $)
       --($ (C.west)!.25!(C.east) $)              --($($ (C.west)!.3!(C.east) $)+(0,3pt)$)
       --($($ (C.west)!.4!(C.east) $)-(0,3pt)$)   --($($ (C.west)!.5!(C.east) $)+(0,3pt)$)
       --($($ (C.west)!.6!(C.east) $)-(0,3pt)$)   --($($ (C.west)!.7!(C.east) $)+(0,3pt)$)
       --($ (C.west)!.75!(C.east) $)              --($ (C.west)!.9!(C.east) $)
       --($($ (C.west)!.9!(C.east) $)-(0,30pt)$);
\end{tikzpicture}



\end{document}

to get this:

enter image description here

The problem is that if I want to resize the circle, the vertical lines gets too short (or too long) and I have to fix the "vertical coordinate" manually.

enter image description here

It is possible to anchor the vertical coordinate relative to the node's shape??

share|improve this question
    
Why does it need to be without decorations? –  Jake May 11 '12 at 10:07
    
I thought this issue was resolved in one of your previous questions. What is your real concern about this picture that has been the subject of 5 questions already? :) Note that, resistor shape must comply with some standards. –  percusse May 11 '12 at 10:12
    
@percusse and jake: in previous questions I used the decoration library but I couldn't fit the shape of the zig-zag lines to my needs. Also the shape I need it's not really a zig zag line. –  Angelo May 11 '12 at 10:24
    
@jake: thank you...the solution was very easy ;) –  Angelo May 11 '12 at 10:29
add comment

1 Answer

up vote 7 down vote accepted

Instead of defining the "legs" as (0,-30pt) (which, of course, doesn't scale), you can use ($(C.north)-(C.south)$):

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}

\node[draw,circle,minimum size=1.2cm] (C) at (0,0){};

\draw    ($($ (C.west)!.1!(C.east) $)-($(C.north)-(C.south)$)$)--($ (C.west)!.1!(C.east) $)
       --($ (C.west)!.25!(C.east) $)--($($ (C.west)!.3!(C.east) $)+(0,3pt)$)
       --($($ (C.west)!.4!(C.east) $)-(0,3pt)$)--($($ (C.west)!.5!(C.east) $)+(0,3pt)$)
       --($($ (C.west)!.6!(C.east) $)-(0,3pt)$)--($($ (C.west)!.7!(C.east) $)+(0,3pt)$)
       --($ (C.west)!.75!(C.east) $)--($ (C.west)!.9!(C.east) $)
       --($($ (C.west)!.9!(C.east) $)-($(C.north)-(C.south)$)$);
\end{tikzpicture}
\begin{tikzpicture}

\node[draw,circle,minimum size=1.8cm] (C) at (0,0){};

\draw    ($($ (C.west)!.1!(C.east) $)-($(C.north)-(C.south)$)$)--($ (C.west)!.1!(C.east) $)
       --($ (C.west)!.25!(C.east) $)--($($ (C.west)!.3!(C.east) $)+(0,3pt)$)
       --($($ (C.west)!.4!(C.east) $)-(0,3pt)$)--($($ (C.west)!.5!(C.east) $)+(0,3pt)$)
       --($($ (C.west)!.6!(C.east) $)-(0,3pt)$)--($($ (C.west)!.7!(C.east) $)+(0,3pt)$)
       --($ (C.west)!.75!(C.east) $)--($ (C.west)!.9!(C.east) $)
       --($($ (C.west)!.9!(C.east) $)-($(C.north)-(C.south)$)$);
\end{tikzpicture}



\end{document}
share|improve this answer
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.