Menu

#121 Undeclared conditional breaks \pgfmath@@declarefunction

Next Release
closed-fixed
None
5
2019-03-06
2019-03-05
No

The following code breaks \pgfmath@@declarefunction.

\pgfmathdeclarefunction{func}{1}{%
  \checkarg{#1}
  \ifchecked
    \def\pgfmathresult{1}%
  \else
    \def\pgfmathresult{0}%
  \fi
}

\newif\ifchecked

\def\checkarg#1{%
  \ifdim#1pt>0pt
    \checkedtrue
  \else
    \checkedfalse
  \fi
}

TeX reports

! Too many }'s.
\pgfmath@@declarefunction ...def #1{#2}\def #2{#4}
\or \def #1##1{\pgfmathpar...

The reason is that when func is declared, \ifchecked has not yet been defined. Tex does not see it as a conditional and interprets the \fi statement in the body of func as closing the \ifcase conditional in \pgfmath@@declarefunction.

The solution is to defer the definition of the function after \ifcase ... \fi.

1 Attachments

Discussion

  • Eric Domenjoud

    Eric Domenjoud - 2019-03-05

    Sorry, this should be a bug report. It ended up in the wrong category and sourceforge does not allow me to move or modify the ticket.

     
  • Henri Menke

    Henri Menke - 2019-03-06
    • status: open --> closed-fixed
    • assigned_to: Henri Menke
     
MongoDB Logo MongoDB