I'm feeling very stupid, but I just can't figure out why \hiOK in the
following works, while \hiKO does not:
-------8<-----------------
\documentclass{minimal}
\usepackage{tikz}
\newcommand{\hiOK}[2][hi]{ \node {#1 #2}; }
\newcommand{\hiKO}[2][hi]{ node {#1 #2} }
\begin{document}
\begin{tikzpicture}
\hiOK{world}
\end{tikzpicture}
\begin{tikzpicture}
\path \hiKO{world} ;
\end{tikzpicture}
\end{document}
-------8<-----------------
with the following error message:
! Package tikz Error: Giving up on this path. Did you forget a semicolon?.
See the tikz package documentation for explanation.
Type H <return> for immediate help.
...
l.22 \path \hiKO
{world} ;
?
I'm using
tikz.sty 2008/02/13 v2.00 (rcs-revision 1.27)
pgf.sty 2008/01/15 v2.00 (rcs-revision 1.12)
Thanks for any help/pointers/advices in advance.
- Lian Tze -
|
|
0
|
|
|
|
Reply
|
Lian
|
9/28/2010 6:46:02 AM |
|
On 28/09/2010 07:46, Lian Tze Lim wrote:
> \documentclass{minimal}
> \usepackage{tikz}
>
> \newcommand{\hiOK}[2][hi]{ \node {#1 #2}; }
> \newcommand{\hiKO}[2][hi]{ node {#1 #2} }
>
> \begin{document}
>
> \begin{tikzpicture}
> \hiOK{world}
> \end{tikzpicture}
>
> \begin{tikzpicture}
> \path \hiKO{world} ;
> \end{tikzpicture}
>
> \end{document}
Your two examples are rather different. In the first case, \hiOK is
expanded by LaTeX to insert the \node macro. So that can scan ahead and
see the ";". On the other hand, in the second example I suspect that
\path scans ahead, sees another macro and stops. So something like
\newcommand*\hiKO[2][hi]{ \path node {#1 #2} }
will work.
--
Joseph Wright
|
|
0
|
|
|
|
Reply
|
Joseph
|
9/28/2010 7:08:32 AM
|
|
On 9/28/10 3:08 PM, Joseph Wright wrote:
>> \newcommand{\hiKO}[2][hi]{ node {#1 #2} }
>> \path \hiKO{world} ;
>
> Your two examples are rather different. In the first case, \hiOK is
> expanded by LaTeX to insert the \node macro. So that can scan ahead and
> see the ";". On the other hand, in the second example I suspect that
> \path scans ahead, sees another macro and stops. So something like
>
> \newcommand*\hiKO[2][hi]{ \path node {#1 #2} }
>
> will work.
Thanks for the explanation! I'll be more careful in defining my commands.
- Lian Tze -
|
|
0
|
|
|
|
Reply
|
Lian
|
9/28/2010 7:33:50 AM
|
|