# Trouble with own macro

I'm not sure where my error is. I uses this code:

\newcommand{\qr}[2]{%
\begin{pspicture}(1.378in, 1.5in)%
\psbarcode[]{#1}{height=1.378 width=1.378}{qrcode}%
{\psset{unit=1.378in}\rput(0.165,0.165){\color{white}#2}}%
\end{pspicture}%
}


The definition seems to be okay.

In this full example

\documentclass[a4paper, 12pt, parskip]{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage{pst-barcode}
\usepackage{auto-pst-pdf}

\newcommand{\qr}[2]{%
\begin{pspicture}(1.378in, 1.5in)%
\psbarcode[]{#1}{height=1.378 width=1.378}{qrcode}%
{\psset{unit=1.378in}\rput(0.165,0.165){\color{white}#2}}%
\end{pspicture}%
}

\begin{document}
\section{Demo}
\qr{1,1}
\end{document}


I get a strange error:

! Extra \endgroup. \endpspicture ->\pst@killglue \endgroup
\egroup \ifdim \wd \pst@hbox =\z@ \e... l.57   \end{pspicture}


What does this mean and how to avoid that?

-
Did you try writing \qr{1}{1}, which is the correct way to pass two arguments? – egreg Dec 7 '11 at 23:36
Oh god how painful. That works! – rekire Dec 7 '11 at 23:39
In the last sentence I linked the full latex code. I'll add it. – rekire Dec 7 '11 at 23:52

\qr{1}{1}

-
That works. But I have to wait to accept this answer. – rekire Dec 7 '11 at 23:41
@rekire: No problem ;-) – Gonzalo Medina Dec 7 '11 at 23:46

If you must (or want to) specify the parameters in that specific (comma-separated) format, you should use something similar to this:

\documentclass{article}
\usepackage{pst-barcode}% http://ctan.org/pkg/pst-barcode

\newcommand{\qr}[1]{\qrbase(#1)}
\def\qrbase(#1,#2){%
\begin{pspicture}(1.378in, 1.5in)%
\psbarcode[]{#1}{height=1.378 width=1.378}{qrcode}%
{\psset{unit=1.378in}\rput(0.165,0.165){\color{white}#2}}%
\end{pspicture}%
}

\begin{document}
\section{Demo}
\qr{1,1}
\end{document}​


However, it is easier to use @Gonzalo's approach.

-
Thank you, another great answer from you :-) – rekire Dec 7 '11 at 23:49