Generating barcodes and QR codes with LaTeX

Slashdot it! Delicious Share on Facebook Tweet! Digg!

Easy to Call

The process of including references to links in a print publication can be difficult because the references must be typed in. However, if they are printed as a QR code, then it is easy to scan the code and use it to quickly call up the website.

Listing 4 shows an example for converting a URL into a QR code that in principle, functions exactly like text. The scanner app can figure out that it is dealing with a link from the prefix http://. In this example, I colored the QR code with blue using the command in the square brackets.

Listing 4

URL to QR Code

&&nonumber
\psbarcode[linecolor=blue]{http://www.linuxuser.de}{}{qrcode}

Figure 2 shows the result in the second position from the left. Although black QR codes offer the greatest amount of contrast and therefore also readability, scanner apps can typically deal with colored QR codes.

The color does need to be dark enough to stand out against the background color. Light-colored QR codes on a dark background present problems. The scanner app must first invert the colors in order to read the code. Not all apps are up to the task of inverting colors.

Quick Connection

WiFi access data can be just as problematic as links when they have to be typed in by hand. However, when access data is represented as a QR code, it becomes easy to quickly create a connection. Listing 5 contains an example for the creation of a corresponding QR code.

Listing 5

Connect to WiFi

&&nonumber
\psbarcode{WIFI:T:WPA;S:MyWLAN;P:MyPassword;;}{}{qrcode}
\uput{0pt}[90]{90}(2.25,0){\textsf{\tiny{WLAN-Zugangsdaten}}}

Once again, you will see the well-known command for the QR code in the first line – except that here the value represents WiFi access data. The scanner app recognizes this from the WIFI: prefix and then typically generates the WiFi connection after a button push. Next comes the type of encryption, the SSID, and the password.

This example includes a command from the PSTricks package in line 2. The command inside the third set of braces is responsible for making the text WiFi access data also appear in the smallest possible san serif font size. It appears at a distance of zero points (value in the first set of curly braces) from the lower left corner (value in square brackets) at an angle of 90 degrees and rotated by 90 degrees (second set of curly braces). You will find the result in Figure 2 in the position second from the right.

Buy this article as PDF

Express-Checkout as PDF

Pages: 3

Price $0.99
(incl. VAT)

Buy Ubuntu User

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Online LaTeX Editors

    You can edit your LaTeX documents with online editors that run across platforms and are device independent. Documents get saved online, thus giving you and other members of a work group easy access from anywhere.

  • Fine-tuning LaTeX documents

    Proofreading, wordsmithing, and finalizing the layout are all steps in the final editing phase of a document. LaTeX used with additional software can help you master these steps.

  • Creating vector graphics with LaTeX and TikZ

    Using LaTeX and the TikZ package, you can create high-quality vector graphics to improve your documents by making them more visually appealing.

  • Minimizing load time for web pages

    Web page loading time relies on a complex interplay among the web server, the web page, and the web browser. Learning a few tricks can help speed up load times for the pages you create.

  • Software for scientific texts

    Scientific documents are where open source tools show their greatest strengths. To save yourself a lot of trouble, however, you need to know how to combine formulas and data into your work. Linux provides the appropriate tools.