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?
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}
For me the following Setup worked:
\usepackage[dvipsnames]{xcolor}
\usepackage[breaklinks=true]{hyperref}
\hypersetup{
colorlinks = true,
linkcolor = NavyBlue,
urlcolor = NavyBlue,
citecolor = NavyBlue,
filecolor = NavyBlue,
}
\usepackage{qrcode}
Apparently, filecolor was the one changing the color of the QR code itself. I prefer NavyBlue, but you could choose any color you like. In this case, using \textcolor does not work and is overwritten by the color options defined on \hypersetup.
\definecolor{myblue}{cmyk}{1.0,0.8,0.05,0.20}– Joost Döbken Oct 13 '17 at 10:03hyperrefin conjuction withcolorlinks=trueand e.g.urlcolor=[named]{blue}, the\textcolor{COLOR}{\qrcode{SOMETHING}}command seems to ignore theCOLOR. – norok2 Jun 12 '18 at 10:31hyperref. – lumbric Mar 06 '20 at 15:08hyperrefand the qrcodes should not be links, add package optionnolinks:\usepackage[nolinks]{qrcode}. You can also use optionnolinkfor\qrcode:\qrcode[nolink]{SOMETHING}or the starred version\qrcode*:\qrcode*{SOMETHING}. – esdd Mar 07 '20 at 17:18\textcolor:\textcolor{COLOR}{\hypersetup{urlcolor=.}\qrcode{SOMETHING}}. But then to have to ensure that\hypersetupis defined. – esdd Mar 07 '20 at 17:22