I am trying to work with a string parsing macro, found in the answer of TeX capacity exceeded while parsing a date string - TeX - LaTeX.
Basically, I have strings num01, num02... num09 - from these, I would like to extract the last character; and this code, for instance, works (with pdflatex):
\documentclass{article}
\def\parseMyNumHelper num0#1\relax{\edef\MyNum{#1}}
\def\parseMyNum#1{\edef\temp{#1}%
\expandafter\parseMyNumHelper\temp\relax}
\begin{document}
\edef\myid{num01}
% \begin{minipage}
\parseMyNum{\myid}
\typeout{ ======== \temp === \MyNum }
% \end{minipage}
\end{document}
... resulting with this in the log output:
...
======== num01=== 1
(./a.aux) )
...
However, now just uncomment the begin/end {minipage} statements; the code immediately crashes with:
...
(./a.aux
)
! Missing number, treated as zero.
<to be read again>
\edef
l.12 \parseMyNum
{\myid}
...
... and even if I proceed a bit with looking at \parseMyNum, I cannot see anything strange:
? i
insert>\show\parseMyNum
! Illegal unit of measure (pt inserted).
<to be read again>
\show
l.12 \parseMyNum
{\myid}
? i
insert>\typeout{ \meaning\parseMyNum }
macro:#1->\edef \temp {#1}\expandafter \parseMyNumHelper \temp \relax
> \parseMyNum=macro:
#1->\edef \temp {#1}\expandafter \parseMyNumHelper \temp \relax .
<insert> \show\parseMyNum
l.12 \parseMyNum
{\myid}
Any ideas why the parsing macro \parseMyNum fails when within a minipage environment - and how to have a similar string parsing macro, working both within and outside of minipage and other environments?
Many thanks in advance for any answers,
Cheers!
minipagelooks for its argument:\begin{minipage}{width}...– Ulrike Fischer May 23 '12 at 10:02\begin{minipage}{\textwidth}then it works again. (Admittedly, this is far from obvious when looking at the log file! But a good debugging strategy is to also comment out the stuff you're trying to debug just to check that without it the document compiles okay.) – Andrew Stacey May 23 '12 at 10:09