# String parsing macro fails within a minipage environment? [closed]

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!

-

## closed as too localized by Frank Mittelbach, Marco Daniel, percusse, Count Zero, Tom BombadilAug 23 '12 at 19:49

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.

minipage looks for its argument: \begin{minipage}{width}... –  Ulrike Fischer May 23 '12 at 10:02
To confirm Ulrike's comment, if you put \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.) –  Loop Space May 23 '12 at 10:09
And indeed it is (looking for it argument) :) Many thanks for that @UlrikeFischer - would you mind posting your comment as an answer, so I can accept it? Cheers! –  sdaau May 23 '12 at 10:12