Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to use the pgf oo library to create a new class. Unfortunately, even this fails:

\documentclass{article}

\usepackage{tikz}
\usepgfmodule{oo}

\pgfooclass{mapEntry}{ %
    \method mapEntry() {%
    }
}

\begin{document}
    \pgfoonew \myObj = new mapEntry()
\end{document}

This is the error message I get:

Runaway argument?
\myObj = new mapEntry() \end {document} 
! File ended while scanning use of \pgfoo@new.
<inserted text> 
            \par

Why does it fail? I found literally nothing useful about this, apart from the tikz manual chapter on the oo library.

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

For some reason, having spaces around the = will break things (even though they are used in the manual). The following code compiles for me:

\documentclass{article}

\usepackage{tikz}
\usepgfmodule{oo}

\pgfooclass{mapEntry}{ %
    \method mapEntry() {%
    }
}

\begin{document}

\pgfoonew \myObj=new mapEntry()

\end{document}
share|improve this answer
2  
The reason that there can't be a space after the equal sign is that \pgfoo@new is defined as \def\pgfoo@new#1=new #2(#3){...} (and \pgfoonew essentially only calls \pgf@new or a variant if there are arguments present). –  Caramdir Jul 21 '11 at 3:34
    
Just happened on this one - hadn't seen it before and wish I had since this took me ages to figure out! –  Andrew Stacey Oct 4 '12 at 14:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.