5

When the text of a QRcode comes from a \newcommand{\TextInsideQRcode}, the spaces between the words vanish. Is there a way to maintain the spaces between the words ?

 \documentclass[]{article}
 \usepackage[]{qrcode}
 \begin{document}

 \newcommand{\TextInsideQRcode}[0]{Here is a newcommand that contains the verbatim text inside the qr code\? In the resulting  QRcode, the spaces between the words vanish. \? Is there a way to maintain the spaces between the words ?} %

 \qrcode[]{\TextInsideQRcode}% 

 \vglue1cm

 \qrcode[]{When a similar verbatim text in directly entered into the qrcode command, the spaces between the words remain intact.}% 

 \end{document}

enter image description here

5

Please read section "2.3 Special characters" of the documentation for package qrcode. \qrcode reads the argument verbatim except for characters \, {, and } to allow macro expansion. These characters and the other special characters including spaces needs an "escaping" with the backslash, because their catcodes are already assigned at the time of the macro definition. The catcode changes in \qrcode come to late.

Example:

\newcommand*{\TextHello}{Hello\ world!}
\qrcode[]{\TextHello}
| improve this answer | |
  • Thanks ! I have read the documentation, but didn't think that a space was a special character. – SDrolet Feb 8 '15 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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