1

I want to create a qrcode matching a predefined template that contains two empty lines. I'm using the qrcode package, and everything is fine, if I just put

\qrcode{a


b}

in my document. The code is generated, and scans with the two empty lines.

However, I absolutely cannot figure out, how to wrap this call in a \newcommand. When I try

\newcommand{\mycode}[2]{%
\qrcode{#1


#2}}

\mycode{a}{b}

I receive the treaded

! Paragraph ended before \qrcode@in was complete.

error. I've read all about how TeX reads the input (the famous "Chapter 8" and more), and when empty lines become \par, etc., but I've failed to find the loophole around this problem. I've tried \char13\char13, which failes with

Missing \endcsname inserted.

So how can I overcome this problem?

2
  • 1
    Welcome to TeX.SX! Can you please expand the code snippet that you have posted to a full minimal working example. It is much easier to help you if we can start with some compilable code that illustrates your problem. A MWE should start with a \documentclass command, include any necessary packages and be as small as possible to demonstrate your problem. At the moment we have to guess what packages etc you are using before we can compile your code.
    – user30471
    Mar 9 '20 at 11:25
  • \newcommand{\mycode}[2]{% \qrcode{#1}\\[+2\baselineskip]\qrcode{#2}}?
    – koleygr
    Mar 9 '20 at 11:26
1

To create a macro, which can call \qrcode in its body and grabs arguments, you should also set \qr@verbatimcatcodes before reading the argument, this way your macro can behave in the same way \qrcode behaves. Additionally, you should use \? to include the newlines, like @egreg already suggested:

\documentclass[]{article}

\usepackage{qrcode}

\makeatletter
\newcommand\mycode
  {%
    \begingroup
    \qr@verbatimcatcodes
    \mycode@
  }
\newcommand\mycode@[2]
  {%
    \qrcode{#1\?\?#2}%
    \endgroup
  }
\makeatother

\begin{document}
\mycode{a}{b}
\end{document}
6

If you're using the qrcode package, you can find the relevant part of the manual:

enter image description here

(page 5).

Use \? instead of an empty line.

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.