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 help on Tikz lindenmayersystem library. In this topic, JLDiaz presented a solution to draw segments of several lengths thanks to the command:

\symbol{S}{\pgflsystemstep=0.6\pgflsystemstep}

Is there a way to do the same thing with angles? I would like to use + or - 60 degree rotation and + or - 85 degree rotation to draw my figure.

I've tried:

\documentclass[tikz]{standalone}
\usepackage{tikz}

\usetikzlibrary{lindenmayersystems}

\begin{document}

\begin{tikzpicture}
\pgfdeclarelindenmayersystem{mySystem}{
    \symbol{a}{\pgflsystemleftangle = 60}
    \symbol{b}{\pgflsystemrightangle = 60}
  \rule{X -> FaF+F-F-F+FbF}
}

\draw  [l-system={mySystem, step=10pt, angle=85, axiom=X, order=1}]
  lindenmayer system ;
\end{tikzpicture}

\end{document}

without any success: "a" and "b" symbol are ignored.

Could you help me on this? Thank you!

share|improve this question

1 Answer 1

up vote 1 down vote accepted

You need to use \def\pgflsystemleftangle{60} or \def\pgflsystemrightangle{60} (note that the manual has some typos and inserts and extra r in the macro names in a couple of places). You can set them both at once with a custom macro as I have done below. Note that the angle remains changed in the current scope.

\documentclass[tikz]{standalone}
\usepackage{tikz}

\usetikzlibrary{lindenmayersystems}
\def\pgflsystemsetangle#1{%
  \def\pgflsystemleftangle{#1}%
  \def\pgflsystemrightangle{#1}%
}
\begin{document}

\begin{tikzpicture}
\pgfdeclarelindenmayersystem{mySystem}{
    \symbol{a}{\pgflsystemsetangle{30}}
    \symbol{b}{\pgflsystemsetangle{60}}
    \symbol{c}{\pgflsystemsetangle{90}}
  \rule{X -> Fa+Fb+Fc+Fa-Fb-Fc-F}
}

\draw  [l-system={mySystem, step=10pt, angle=85, axiom=X, order=1}]
  lindenmayer system ;
\end{tikzpicture}

\end{document}

enter image description here

share|improve this answer
    
Thank you! That's exactly what I need! –  Tobard Feb 25 at 17:06

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.