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?

4
  • Can you give full code starting from \documentclass and ending at \end{document}?
    – user11232
    Commented Mar 27, 2015 at 10:44
  • As far as I know, the icon needs to be always taken into account whhen computing the QR code.
    – yo'
    Commented Mar 27, 2015 at 10:45
  • possibly related: How to add text into a QR-Code? Commented Mar 27, 2015 at 12:35
  • 1
    Not related, but you should read: why-should-the-minimal-class-be-avoided
    – Ignasi
    Commented Mar 27, 2015 at 14:53

1 Answer 1

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

You must log in to answer this question.

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