2

What I want

A qr-code which generates the following link:

https://www.ctan.org/tex-archive/macros/latex/contrib/qrcode?lang=en?utm_source=test&utm_medium=test&utm_campaign=test%20test&utm_term=test&utm_content=test

What I get

https://www.ctan.org/tex-archive/macros/latex/contrib/qrcode?lang=#2?utm_source=test&utm_medium=test&utm_campaign=test%20test&utm_term=test&utm_content=test

The problem

#2 doesn't render to en.

MWE

\documentclass{article}

\usepackage{tikz}
\usepackage{qrcode}

\newcommand{\myqrcode}[2]{%
    \draw (#1) node {\qrcode[height=5cm]{https://www.ctan.org/tex-archive/macros/latex/contrib/qrcode?lang=\#2?utm_source=test\&utm_medium=test\&utm_campaign=test\%20test\&utm_term=test\&utm_content=test}};
}

\begin{document}

\begin{tikzpicture}
    \myqrcode{0,0}{en}
\end{tikzpicture}

\end{document}
  • 1
    Shouldn't it be #2 instead of \#2? – egreg Jan 3 '18 at 11:11
  • Oh! I escaped too much. – Sr. Schneider Jan 3 '18 at 11:12
2

You should use \# if you want to get a literal # in the URL. In this case you want TeX to substitute a parameter, so you need

qrcode?lang=#2?utm_source=test\&utm_medium=test

(& should indeed be escaped).

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.