Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TikZ does not allow long macros #1074

Closed
ilyaza opened this issue Nov 10, 2021 · 3 comments
Closed

TikZ does not allow long macros #1074

ilyaza opened this issue Nov 10, 2021 · 3 comments

Comments

@ilyaza
Copy link

ilyaza commented Nov 10, 2021

Brief outline of the bug

If a macro inside a TikZ command produces only “simple” operations, then (without the enclosed patch) the length of the macro is severely bounded. (Currently, there is a code to work around this, but it only triggered if a “complicated” primitive is issued.)

--- tikz.code.tex-orig	2021-08-23 19:38:15.955899500 -0700
+++ tikz.code.tex	2021-11-09 16:05:40.344118700 -0800
@@ -2173,6 +2173,7 @@
       \fi%
     \fi%
   \fi%
+  \ifx\pgfutil@next\tikz@handle@more\else\tikz@expandcount=100\relax\fi%
   \pgfutil@next%
 }%

Minimal working example (MWE)

\documentclass{article}
\usepackage{tikz}
\begin{document}

% Part of output of: perl -wle "sub B($){(my $p=reverse shift) =~ tr/RDLU/DLUR/; $p} sub D($$);sub D($$) {my ($p,$c)=(shift,shift); $c>0 ? ($p=D($p, $c-1), $p.B $p) : $p} print join q(\\), q(), split //, D q(R), $_ for 0..7"
\def\DRx{\R\D\L\D\L\U\L\D\L\U\R\U\L\U\L\D\L\U\R\U\R\D\R\U\L
         \U\R\U\L\U\L\D\L\U\R\U\R\D\R\U\R\D\L\D\R\D\R\U\L\U
         \R\U\R\D\R\U\L\U\R\U\L\U\L\D\L\U\R\U\R\D\R\U\R\D\L
         \D\R\D\R\U\R\D\L\D\L\U\L\D\R\D\L\D\R\D\R\U\L\U\R\U
         \R\D\R\U\R\D\L\D\R\D\R\U\L\U\R\U\R\D\R\U\L\U\R\U\L}

\tikz{ \def\R{ -- ++(1,0) }%    Poor man's l-system
       \def\U{ -- ++(0,1) }
       \def\L{ -- ++(-1,0) }
       \def\D{ -- ++(0,-1) }
       \draw[rounded corners=2mm] (0,0) \DRx ;}

\end{document}
@muzimuzhi
Copy link
Member

muzimuzhi commented Nov 10, 2021

I think this is a duplicate of #969, which is already fixed in #970 and the fix is available since v3.1.9.

Edit: Also, tikz's turtle library maybe an alternative in drawing your example.

@hmenke
Copy link
Member

hmenke commented Nov 10, 2021

Not reproducible on either up-to-date TL2021 or latest master.

@hmenke hmenke closed this as completed Nov 10, 2021
@ilyaza
Copy link
Author

ilyaza commented Nov 20, 2021

Just for completeness: I have been testing this with the stock TeXLive2021. Thanks for fixing this in the current version!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants