2

I'm trying to create an animation of a geometrical figure using Tikz and the animate package, in which I want to typeset the angles between lines frame by frame. I can actually achieve this, however when I want to change the font size of the angles I get the following error:

! TeX capacity exceeded, sorry [input stack size=5000].
\pgf@selectfontorig ->\pgf@selectfontorig 
                                          \nullfont 
l.43   }

The MWE describing the problem is provided here below.

MWE:

\documentclass[a4paper,10pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{animate}
\usetikzlibrary{shapes.geometric, calc, positioning, decorations.text}
\newlength{\R}\setlength{\R}{6cm}

\def\hbb{-2cm}
\def\wbb{6cm}
\def\frate{10}

\begin{document}
\begin{animateinline}[poster=first, controls,autoplay, width=\textwidth, keepaspectratio, begin={\begin{tikzpicture} \useasboundingbox (\hbb,\hbb) rectangle (\wbb,\wbb);}, end={\end{tikzpicture}}]{\frate}
\newframe[\frate]
  \begin{tikzpicture}
    \useasboundingbox (\hbb,\hbb) rectangle (\wbb,\wbb);
    \node [circle, fill=none, draw=black, minimum size=\R, thick] (BaseCircle)  {};
    \node [circle, fill=none, draw=black, minimum size=0.25\R, thick] (Hole) {};

  \end{tikzpicture} 
  
\multiframe{4}{n=1+1}{
      \begin{tikzpicture}
    \useasboundingbox (\hbb,\hbb) rectangle (\wbb,\wbb);

    \node [circle, fill=none, draw=black, minimum size=\R, thick] (BaseCircle)  {};
    \node [circle, fill=none, draw=black, minimum size=0.25\R, thick] (Hole) {};
    
    \foreach \j in {1,...,\n}{
        
        \pgfmathsetmacro\startangle{30*\j}
        \pgfmathsetmacro\endangle{\startangle + 30}
        
        \draw [draw=blue, -latex, postaction={decorate},decoration={text along path, text color=blue, text={{}|{\small}|{$\theta/n$} {}}, text align=center, raise=3pt}] +(\startangle:0.2\R) arc  [start angle=\startangle, end angle=\endangle, radius=0.2\R] {};
    }
    
  \end{tikzpicture} 
  }

  \end{animateinline}
\end{document}

So, as soon as I remove the \small macro in the code, the animation works as expcted, but it turns out the text along the path is too big for my purposes. I have also tried with \fontsize{6}{6}\selectfont to reduce the font size, but no luck so far.

I also thought it could be a problem with the tikz decorations library, so I moved to the old school way and defined a node containing the text in a sloped fashion, using this:

\draw [draw=blue, -latex] +(\startangle:0.2\R) arc  [start angle=\startangle, end angle=\endangle, radius=0.2\R] node [pos =0.5, sloped, above] {\small Test} ;

But I get the same error. I have to say that this actually works and the document is compiled with no errors without the animateinline environment.

Update1:

The issue isn't related to the compiler. I have tested the MWE with PDFLaTeX, XeLaTeX and LuaLaTeX. However the error remains the same.

In any case, the document isn't generated at all.

Update2:

Following the recommendations of the animate package in the documentation (section 10), in order to increase memory and stack input size, does not solve the problem either. Since I have Linux, the recommendation is to do the following:

  1. Find the configuration file ‘texmf.cnf’ by means of kpsewhich texmf.cnf at the shell prompt in a terminal.
  1. As Root, open the file in your favourite text editor, scroll to the ‘main_memory’ entry and change it to the value given above; save and quit.
  1. Rebuild the formats by

fmtutil-sys --byfmt latex

fmtutil-sys --byfmt pdflatex

fmtutil-sys --byfmt xelatex

I must add that I had to run the fmutil-sys command as root, because otherwise it didn't succeed. I don't know if that could be a possible cause of the problem.

Update3:

When increasing the stack size to 500000, the error differs slightly and becomes to:

! TeX capacity exceeded, sorry [input stack size=30000].
\pgf@selectfontorig ->\pgf@selectfontorig 
                                          \nullfont 
l.43   }

So, [input stack size=30000] instead of [input stack size=5000].

Update4

I tried to change the space between the denominator and the numerator of the fraction (angle), following an answer given here: too little space between the bar on the denominator and the horizontal line

I defined a custom fraction and interestingly a similar error is produced. It seems a font modification of some sort is not permitted or something.

Any suggestions? What I'm doing wrong here?

Best,

C.

2 Answers 2

4

Edit: After further investigation of examples in TikZ & PGF manual, examples on pages 660 -- 661 I succeed to define different font size in decorate environment as is in the rest of animate code and document. So try the following MWE, which in comparison to your MWE has the following changes:

  • decoration is defined as option of tikzpicture and not as path's option in loop
  • in decoration is instead text along path used text effects along path
  • the options of path inside loop are defined as
\path   [postaction={decorate},                             % <--- changed
         text effects={text along path, font=\scriptsize}]  % <--- new
        (\startangle:\R/2) arc (\startangle:\endangle:\R/2);

Complete MWE is:

\documentclass[border=3.141592mm]{standalone}
\usepackage{tikz}
\usepackage{animate}
\usetikzlibrary{decorations.text}
\tikzset{
    C/.style = {circle, draw, thick, minimum size=#1},
        }
\newlength{\R}\setlength{\R}{2cm}

\def\hbb{4cm}
\def\wbb{3.2cm}
\def\frate{10}

\begin{document}

    \begin{animateinline}[poster=first, controls, autoplay,
                          ]{\frate}
\multiframe{12}{n=1+1}%
{
\begin{tikzpicture}[
decoration={text effects along path, reverse path,
            text={~{$\theta_{\i}$}~},
            text align=center,
            raise=3pt
            }
                    ]
\useasboundingbox (-\wbb,-\hbb) rectangle (\wbb,\hbb);
%
\node [C=3\R]   (BaseCircle)  {};
\node [C= \R]   (Hole) {};

\foreach \i in {1,...,\n}
{
\pgfmathsetmacro\startangle{30*(\i-1)}
\pgfmathsetmacro\endangle{\startangle + 30}
%
\path   [postaction={decorate},
         text effects={text along path, font=\scriptsize}]
        (\startangle:\R/2) arc (\startangle:\endangle:\R/2);
}
\end{tikzpicture}
}
    \end{animateinline}
$\theta_{12}$
\end{document}

Compiling it (with recent version of the MiKTEX bundle) gives:

enter image description here

For comparison are added $\theta_{11}$ at above right corner of animate bounding box and $\theta_{12}$ at below right corner of document. Both has normal font size.

Edit: If you like to have marked angle range, that you only need to change options of path in the loop:

\draw   [<->, thin, blue,                                     % <--- new
         postaction={decorate},                             % <--- changed
         text effects={text along path, font=\scriptsize}]  % <--- new
        (\startangle:0.6\R) arc (\startangle:\endangle:0.6\R);

enter image description here

3
  • 1
    @Charlie, see if edited answer gives what you after.
    – Zarko
    Oct 31, 2021 at 12:43
  • Thanks for your answer. It actually does what I need and I appreciate your complete solution and investigation! Thank you!
    – Charlie
    Oct 31, 2021 at 20:49
  • 1
    @Charlie, you are welcome!
    – Zarko
    Oct 31, 2021 at 21:06
0

So, technically this is not changing the font size of the text and it doesn't answer the original question.

Applying a scaling on the node, in this case produces the same effect as reducing the font size of the text. This is actually not valid for the text along path, and for this reason I consider it an "acceptable" workaround.

\draw [draw=blue, -latex] +(\startangle:0.2\R) arc  [start angle=\startangle, end angle=\endangle, radius=0.2\R] node [pos =0.5, sloped, above, scale=0.65, text=blue] {$\dfrac{\theta}{n}$} ;

Since no other answers have been provided yet, I won't mark this one as the accepted answer.

You must log in to answer this question.

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