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'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?

share|improve this question
5  
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

2 Answers 2

up vote 14 down vote accepted

Your command receives two mandatory arguments, so you have to use

\qr{1}{1}
share|improve this answer
    
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}​

enter image description here

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

share|improve this answer
1  
Thank you, another great answer from you :-) –  rekire Dec 7 '11 at 23:49

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.