3

I like the simple implementation for QR codes in Latex, for example:

\usepackage{qrcode}

...

\qrcode[height=1in]{https://www.ctan.org/tex-archive/macros/latex/contrib/qrcode?lang=en}

But... is it possible to change the color?

7

Like for other elements in LaTeX:

\documentclass{article}

%\usepackage{xcolor}
\usepackage{qrcode}

\begin{document}
\textcolor{blue}{\qrcode[height=1in]{https://www.ctan.org/tex-archive/macros/latex/contrib/qrcode?lang=en}}
\end{document}

You even don't need to load xcolor, because qrcode already loads xcolor (without using it). But you can load it before qrcode, if you want to add options:

\documentclass{article}

\usepackage[svgnames]{xcolor}
\usepackage{qrcode}

\begin{document}
\textcolor{DarkBlue}{\qrcode[height=1in]{https://www.ctan.org/tex-archive/macros/latex/contrib/qrcode?lang=en}}
\textcolor{Blue}{\qrcode[height=1in]{https://www.ctan.org/tex-archive/macros/latex/contrib/qrcode?lang=en}}
\textcolor{LightBlue}{\qrcode[height=1in]{https://www.ctan.org/tex-archive/macros/latex/contrib/qrcode?lang=en}}

\end{document}

qrcode with different colors

Note: The contrast of QR-Codes should be high. So the last one at the example above shouldn't be used!

This does work for all colors, e.g., a self defined:

\documentclass{article}

\usepackage{qrcode}
\definecolor{myblue}{cmyk}{1.0,0.8,0.05,0.20}

\begin{document}
\textcolor{myblue}{\qrcode[height=1in]{https://www.ctan.org/tex-archive/macros/latex/contrib/qrcode?lang=en}}

\end{document}

with self defined color

  • unfortunately this doesn't seem to work for self-defined colors \definecolor{myblue}{cmyk}{1.0,0.8,0.05,0.20} – Joost Döbken Oct 13 '17 at 10:03
  • 1
    @API: Surely it does! – Schweinebacke Oct 13 '17 at 10:05
  • 3
    When using hyperref in conjuction with colorlinks=true and e.g. urlcolor=[named]{blue}, the \textcolor{COLOR}{\qrcode{SOMETHING}} command seems to ignore the COLOR. – norok2 Jun 12 '18 at 10:31

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.