# QR codes in LaTeX

> Load the qrcode package and \qrcode[height=2cm]{https://example.com} draws a pure-vector code with LaTeX's own drawing commands — no external images, no shell-escape, and it prints at any size without pixelation. Set level=H for logos, keep the quiet zone, and size beamer codes for the back row.

Source: https://useqr.app/docs/developers/qr-codes-in-latex · Last reviewed 2026-08-21 · UseQR is free forever, MIT licensed, no signup.

---

## The qrcode package

```latex
\usepackage{qrcode}
...
\qrcode{https://example.com}
\qrcode[height=2cm]{https://example.com}
\qrcode[height=2cm, level=H]{https://example.com/paper}
```

What makes this package the right default: it encodes and draws the code **inside TeX**,
using native drawing primitives. The output is pure vector — no image file, no
shell-escape, no network — so the code stays razor-sharp at any print size, which is the
same reason [print work wants SVG](/docs/print/why-you-should-print-qr-codes-from-svg)
elsewhere.

Useful options:

| Option | Meaning |
|---|---|
| `height=2cm` | rendered size (width equals height) |
| `level=L\|M\|Q\|H` | [error-correction level](/docs/spec/error-correction-levels-explained) |
| `version=5` | force a symbol [version](/glossary/version) |
| `padding` | draw the surrounding quiet zone as part of the symbol |
| `nolinks` | do not make the code a clickable hyperlink |

Two of those deserve expansion. `padding` guarantees the 4-module
[quiet zone](/glossary/quiet-zone) travels with the code — without it, a code placed
against a coloured box or margin note can end up with no clear border and
[fail to scan](/docs/troubleshooting/qr-code-quiet-zone-too-small). And when `hyperref` is
loaded, the drawn code is itself a hyperlink in the PDF — a genuinely nice touch for
documents read on screen — with `nolinks` to opt out.

Set document-wide defaults once:

```latex
\qrset{height=2cm, level=M, padding}
```

## Sizing: print vs projection

For a code on paper scanned at arm's length, `height=2cm` sits at the practical
[print floor of 2 × 2 cm](/docs/print/qr-code-size-for-print). For a beamer slide the
arithmetic changes completely: the reader is metres from a projection, and the **10:1
rule** applies — minimum code width ≈ viewing distance ÷ 10. A seminar room where the
back row sits 8 m from the screen needs the code to be ~80 cm wide *as projected*, which
on a standard 16:9 frame means the code occupies roughly a quarter of the slide width.
The full working is in [QR size on a TV screen](/docs/print/qr-code-size-on-a-tv-screen).
Leave the slide up for a sensible interval too — people need time to raise a camera.

## The includegraphics route

If you need styling the package cannot draw (brand colours, custom modules), generate a
vector file from the [keyless API](/docs/developers/free-qr-code-api-no-key) and place it
like any figure:

```bash
curl -o qr.svg "https://useqr.app/api/v1/qr?data=https://example.com&format=svg"
rsvg-convert -f pdf -o qr.pdf qr.svg
```

```latex
\includegraphics[width=2cm]{qr.pdf}
```

pdfLaTeX cannot read SVG directly, hence the PDF conversion step (`rsvg-convert`,
Inkscape, or `svg2pdf` all work). Anything styled should be verified before the camera-
ready deadline — `GET /api/v1/verify` with the same parameters reports whether the code
still decodes.

## FAQ

### How do I put a QR code in a LaTeX document?
Load the qrcode package and write \qrcode[height=2cm]{your-url}. The code is drawn as vector graphics by TeX itself, with no external tools.

### Is the LaTeX qrcode package output print-quality?
Yes — it is pure vector, so it cannot pixelate. Keep the height at 2 cm or more for close-range scanning and preserve the quiet zone with the padding option.

### How big should a QR code be on a beamer slide?
Use the 10:1 rule against the projection: viewing distance divided by ten. For a back row 8 m away, the projected code needs to be about 80 cm wide.

### Can I use a coloured or logo QR code in LaTeX?
The package draws plain black codes. For styled ones, download an SVG from the keyless API, convert to PDF, includegraphics it, and verify it still decodes.

## Try it

- https://useqr.app/url
- https://useqr.app/json
- https://useqr.app/validate
