# Define the color of a QR code

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?

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}


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}


• 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
• @API: Surely it does! – Schweinebacke Oct 13 '17 at 10:05
• 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