4

Some people like having a icon in the centre of their QR code... I want to use the QRCode library to produce such a QR code.

qrcode with icon

For now, I'm using

\documentclass[landscape,8pt]{minimal}
\usepackage{varwidth}
\usepackage{tikz}
\usepackage[]{qrcode}
\usepackage{graphicx}
\setkeys{Gin}{keepaspectratio}
\begin{document}
\topskip0pt
% https://github.com/zxing/zxing/wiki/Barcode-Contents
\centering\noindent\resizebox*\textwidth\textheight{\begin{varwidth}{\textwidth}%
\begin{tabular}{@{}c@{}}%
%
%
\begin{tikzpicture}[node distance=2mm]
\node (qrc) {\qrcode[]{WIFI:T:WPA;S:trololol;P:"12345678";;}};
\node [anchor=center,fill=white,inner sep=4pt,scale=0.02] 
    (icon) at (qrc.center) {\includegraphics{wifi}};
\end{tikzpicture}
%
%
\end{tabular}%
\\%
\centering 12345678
\end{varwidth}}
\end{document}

to generate it, but it feels a bit weird, having to scale the icon manually. Also, I'm guessing that if the icon is big enough, the error recovery capabilities of the qrcode need to be adapted.

Is there any more convenient way of including such a centrally placed icon?

2

Labels can be added at center of nodes. You can use this option instead of an independent node.

\documentclass[landscape,8pt]{article}
\usepackage{varwidth}
\usepackage{tikz}
\usepackage[]{qrcode}
\usepackage{graphicx}
\setkeys{Gin}{keepaspectratio}
\begin{document}
\topskip0pt
% https://github.com/zxing/zxing/wiki/Barcode-Contents
\centering\noindent\resizebox*\textwidth\textheight{\begin{varwidth}{\textwidth}%
\begin{tabular}{@{}c@{}}%
%
%
\begin{tikzpicture}[node distance=2mm]
\node[label={[anchor=center, fill=white, scale=0.02]center:{\includegraphics{wifi}}}] (qrc) {\qrcode[]{WIFI:T:WPA;S:trololol;P:"12345678";;}};
\end{tikzpicture}
%
%
\end{tabular}%
\\%
\centering 12345678
\end{varwidth}}
\end{document}

enter image description here

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.