16

https://tex.stackexchange.com/a/88762/17049 provides a beautiful solution for getting spirals like this:

enter image description here

I've been trying to use this with some mixed text/math content (for a book cover), but I find that even with a tiny excerpt, pdflatex just keeps running and running without terminating. [Using a full core for at least 10 minutes.] The only change I made was to replace

Lorem ipsum ...

in the code in the linked answer with If $K \leq G$ and there are inclusions $gKg^-1\leq K$ for every $g\in G$, ... .

Is there any way of getting spirals with mixed text/maths content, either by modifying the linked answer or otherwise?

MWE:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.text}

\makeatletter

\let\pgf@lib@dec@text@dobox@original=\pgf@lib@dec@text@dobox%

\def\pgf@lib@dec@text@dobox{%
    \pgf@lib@dec@text@dobox@original%
    \ifpgfdecorationtextalongpathscaletext%
    \pgfmathparse{\pgf@lib@dec@text@endscale+(\pgf@lib@dec@text@startscale-\pgf@lib@dec@text@endscale)*\pgfdecoratedremainingdistance/\pgfdecoratedpathlength}%
    \setbox\pgf@lib@dec@text@box=\hbox{\scalebox{\pgfmathresult}{\box\pgf@lib@dec@text@box}}%
    \fi%
}
\newif\ifpgfdecorationtextalongpathscaletext
\def\pgf@lib@dec@text@startscale{1}
\def\pgf@lib@dec@text@endscale{1}

\pgfkeys{/pgf/decoration/.cd,
    text path start scale/.code={%
        \pgfdecorationtextalongpathscaletexttrue%
        \def\pgf@lib@dec@text@startscale{#1}%
    },
    text path end scale/.code={%
        \pgfdecorationtextalongpathscaletexttrue%
        \def\pgf@lib@dec@text@endscale{#1}%
    }
}
\begin{document}    
\begin{tikzpicture}[
    decoration={
    reverse path,
    text along path,
    text path start scale=1.5,
    text path end scale=0,
    text={If $K \leq G$ and there are inclusions $gKg^-1\leq K$  for every $g\in G$, ... .}}
]
\draw [decorate] 
    (0,0) 
    \foreach \i [evaluate={\r=(\i/2000)^2;}] in {0,5,...,2880}{ -- (\i:\r)}; 
\useasboundingbox (-2.75,-2.75) rectangle (2.75,2.75); 
\end{tikzpicture}    
\end{document}

2 Answers 2

5

Your code works if you do as Herbert did in his pstricks example -- Enclose the math in curly braces:

If {$K \leq G$} and there are inclusions {$gKg^-1\leq K$}  for every {$g\in G$}, ...

The problem is that long bits of math are treated as a unit, so you will have to break them up:

{$g$}{$K$}{$g^{-1}$} {$\leq$} {$K$}

I fixed a problem I'd not noticed with the {-1}, which also has to be in its own curly braces.

1
11

It needs latex->dvips->ps2pdf. xelatex doesn't work in this case. It should be easy to adopt it to a TikZ solution, if really needed.

\documentclass[pstricks]{standalone}
\usepackage[T1]{fontenc}
\usepackage{mathptmx,pst-plot,pst-text}

\newdimen\MyDim \MyDim=30pt
\makeatletter
\def\doPerChar#1#2\@nil{%
    \CharacterAction{#1}%
    \ifx\relax#2\relax\else\doPerChar#2\@nil\fi}
\def\perChar#1{\doPerChar#1\@nil}
\def\CharacterAction#1{%
  \fontsize{\MyDim}{1.1\MyDim}\selectfont#1%
  \global\advance\MyDim by -0.175pt}
\makeatother

\pagestyle{empty}
\begin{document}

\begin{pspicture}(-3.5,-3)(3,3)
\pstextpath{%
  \parametricplot[linestyle=none,plotpoints=5000,algebraic,unit=0.2]
    {50}{0}[/A 5e-3 def ]{A*(cos(t)+t^2*sin(t)) | A*(sin(t)-t^2*cos(t))}}{\perChar{%
     {$a$}{$\!^2$}+{$b$}{$\!^2$}={$c$}{$\!^2$}~is~from~Pythagoras~%
     who~lived~in~Greek.~{$\sin^2x+\cos^2x=1$}~is~also~from~him~and~%
     the~same~in~geometry~\ldots}}
\end{pspicture}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .