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}
2
  • 1
    Shouldn't it be #2 instead of \#2?
    – egreg
    Commented Jan 3, 2018 at 11:11
  • Oh! I escaped too much. Commented Jan 3, 2018 at 11:12

1 Answer 1

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).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .