Files
businesscard-qrcode/README.md
T

484 lines
16 KiB
Markdown
Raw Normal View History

2018-08-14 23:10:09 +02:00
Businesscard with QR-Code
=========================
2018-08-11 22:54:09 +00:00
2026-04-30 17:34:16 +02:00
What happens when you hand someone a business card? Either they type everything manually, or the card gets forgotten. This class generates a print-ready business card with a QR code that embeds a full [vcard], so contact data can be imported directly with a scanner [app].
2018-08-13 15:24:59 +02:00
2026-04-30 17:34:16 +02:00
Compared to templates that place many cards on A4, this project focuses on professional printing workflows: one card per PDF page, exact dimensions, and crop marks.
2018-08-12 00:59:57 +02:00
2025-11-09 11:03:42 +01:00
[![Example: John Doe from Hongkong](screenshots/john-doe-hongkong.png)](examples/john-doe-hongkong.tex)
[![Example: Businesscard of Peter Muster from Zürich](screenshots/peter-muster-example-company-zuerich.png)](examples/peter-muster-example-company-zuerich.tex)
2026-04-30 17:34:16 +02:00
[![Example: Nearly Real Example Of My Card](screenshots/example.png)](examples/example.tex)
2018-08-14 23:10:09 +02:00
Features
========
2026-04-30 17:34:16 +02:00
- full contact payload in QR code (vCard 4.0)
- privacy control per field via optional `[hide]` (in QR only, not printed)
- configurable layout: alignment, icon placement, text/QR order, spacing, card dimensions
- professional print output with crop marks and exact paper/content size
- visual customization: logos, QR-center logo, background image/color, text color, QR color
- social/contact integrations ([jabber], [matrix], [gitea], [github], [git], [facebook], [twitter], [youtube], [wikipedia], [nextcloud federation id])
- PGP key URL and fingerprint support
- multi-page PDFs (e.g. front/back variants) with `\newcard`
2018-08-14 23:10:09 +02:00
2026-04-30 17:34:16 +02:00
Quick Start
===========
```latex
\documentclass{businesscard-qrcode}
\type{home}
\givennames{An}
\familynames{Example}
\street{Einbahnstrasse\ 84}
\city{Irgendwo}
\zip{1001}
\country{Switzerland}
\homepage{example.com}
\email{name@example.com}
\begin{document}
\drawcard
\end{document}
```
Compile with:
```bash
xelatex -interaction=nonstopmode your-card.tex
```
2018-08-14 23:10:09 +02:00
Installation
2026-04-30 17:34:16 +02:00
============
2018-08-14 23:10:09 +02:00
2026-04-30 17:34:16 +02:00
Copy `businesscard-qrcode/businesscard-qrcode.cls` to your LaTeX class path. Simplest way on Linux:
2018-08-14 23:10:09 +02:00
```bash
2026-04-30 17:34:16 +02:00
mkdir -p ~/texmf/tex/latex/businesscard-qrcode
2018-08-14 23:10:09 +02:00
cp businesscard-qrcode/businesscard-qrcode.cls ~/texmf/tex/latex/businesscard-qrcode/
2025-11-08 17:09:38 +01:00
ln -s ~/texmf/tex/latex ~/texmf/tex/xelatex
2018-08-14 23:10:09 +02:00
```
2026-04-30 17:34:16 +02:00
Compilation Notes
=================
2018-08-14 23:10:09 +02:00
2026-04-30 17:34:16 +02:00
- Use **`xelatex`** (UTF-8 support, e.g. umlauts, CJK).
- Do **not** load `inputenc` with this class.
- vCard line endings default to CRLF (`crlf` option) for better iOS import compatibility.
### Building with latexmk / IDEs
Editors such as VS Code LaTeX Workshop usually call `latexmk` from the workspace root. This repository ships project-local `.latexmkrc` files (root and `examples/`) that extend `TEXINPUTS` so TeX prefers the local class file from this checkout.
If you invoke `xelatex` manually without `latexmk`, set:
```bash
TEXINPUTS=/path/to/businesscard-qrcode:
```
2018-08-14 23:10:09 +02:00
2026-04-30 17:34:16 +02:00
(or run from the repository root).
2025-11-08 17:09:38 +01:00
2018-08-14 23:10:09 +02:00
Document Structure
2026-04-30 17:34:16 +02:00
==================
2018-08-14 23:10:09 +02:00
```latex
\documentclass[<layout-options>]{businesscard-qrcode}
<data-definitions>
\begin{document}
2026-04-30 17:34:16 +02:00
\drawcard
2018-08-14 23:10:09 +02:00
\end{document}
```
2025-11-11 10:53:12 +01:00
Escaping Spaces in Data
2026-04-30 17:34:16 +02:00
=======================
2025-11-11 10:53:12 +01:00
2026-04-30 17:34:16 +02:00
Spaces inside macro arguments must be escaped as `\ `, otherwise TeX may collapse them before QR/vCard generation.
2025-11-11 10:53:12 +01:00
```latex
\company{Example\ Company\ Ltd.}
\city{New\ York}
\phone{+41\ 44\ 123\ 45\ 67}
```
2018-08-14 23:10:09 +02:00
Layout Options
2026-04-30 17:34:16 +02:00
==============
2018-08-14 23:10:09 +02:00
2026-04-30 17:34:16 +02:00
You can set layout options in four ways:
2018-08-14 23:10:09 +02:00
2026-04-30 17:34:16 +02:00
1. `\documentclass[...]` (global defaults)
2. `\cardsetup{key=value,...}` (runtime/global from that point)
3. `\drawcard[key=value,...]` (runtime, convenient per page/card)
4. command-style setters `\set...{...}` (one setter per option)
2018-08-14 23:10:09 +02:00
2026-04-30 17:34:16 +02:00
Note: direct commands like `\paperwidth{...}` or `\color{...}` would clash with core LaTeX commands/lengths, therefore the command API uses `\set...{...}` names.
2018-08-14 23:10:09 +02:00
2026-04-30 17:34:16 +02:00
```latex
\documentclass[textwidth=0.7,qrwidth=0.25,www,nofill,iconright,rightalign,hint,icon,textfirst]{businesscard-qrcode}
```
2018-08-14 23:10:09 +02:00
2026-04-30 17:34:16 +02:00
```latex
% runtime/global
\cardsetup{textfirst,noicon,qrwidth=0.35}
2025-11-11 10:53:12 +01:00
2026-04-30 17:34:16 +02:00
% per card/page
\drawcard[noqr,noheader,layout=centered]
2018-08-14 23:10:09 +02:00
2026-04-30 17:34:16 +02:00
% command-style
\setqrwidth{0.35}
\seticon{false}
\setlayout{centered}
```
2018-08-14 23:10:09 +02:00
2026-04-30 17:34:16 +02:00
### Paper and Geometry
2018-08-14 23:10:09 +02:00
2026-04-30 17:34:16 +02:00
- `paperwidth=`: physical paper width, default `89mm`
- `paperheight=`: physical paper height, default `59mm`
- `contentwidth=`: inner content width, default `85mm`
- `contentheight=`: inner content height, default `55mm`
- `padding=`: inner padding, default `2mm`
- `cutdist=`: crop-mark distance, default `2`
- `cutlen=`: crop-mark length, default `1`
2018-08-14 23:10:09 +02:00
2026-04-30 17:34:16 +02:00
### Typography and Layout
2018-08-14 23:10:09 +02:00
2026-04-30 17:34:16 +02:00
- `fontsize=`: one of `8pt,9pt,10pt,11pt,12pt,14pt,17pt,20pt`, default `8pt`
- `textwidth=`: relative text block width, default `0.50`
- `qrwidth=`: relative QR block width, default `0.40`
- `qrfirst` / `textfirst`: QR left/right order, default `qrfirst`
- `header` / `noheader`: show/hide top name block + separator line, default `header`
- `qr` / `noqr`: show/hide QR block, default `qr`
- `layout=`: `standard` (default) or `centered`
2026-04-30 19:43:03 +02:00
- `headeremphasis=`: `person` (default), `company`, or `balanced`
2026-04-30 17:34:16 +02:00
- `rightalign` / `leftalign`: text alignment, default `rightalign`
- `iconleft` / `iconright`: icon side, default `iconleft`
- `fill` / `nofill`: fill space between icon and text, default `fill`
2018-08-14 23:10:09 +02:00
2026-04-30 17:34:16 +02:00
### Address, Links, and Formatting
2018-08-14 23:10:09 +02:00
2026-04-30 17:34:16 +02:00
- `address` / `noaddress`: include address in print + vCard, default `address`
- `hint` / `nohint`: show small protocol hints, default `hint`
- `icon` / `noicon`: show icons, default `icon`
- `https` / `www`: hint URL style, default `https`
- `lang=`: wikipedia language prefix, default `de`
- `countryformat=`: `auto` (default), `inline`, or `below`
- `crlf` / `nocrlf`: vCard newline style, default `crlf`
### Colors and QR Tuning
- `color=`: global text color, default `black`
- `qrcolor=`: QR module color, default `black`
- `qreclevel=`: `L`, `M`, `Q`, `H`, default `H`
- `qrlogoscale=`: QR-center logo size fraction, default `0.25`
- `qrlogoborder=`: QR-center logo padding fraction, default `0.02`
- `qrbgopacity=`: QR white background opacity, default `1.0`
### Logo and Background
- `logoheight=`: default logo height near name (with unit). Auto-default: `4em` if company exists, else `2em`
- `bgscale=`: background image scale, default `1.0`
- `bgopacity=`: background image opacity, default `1.0`
2026-04-30 18:46:28 +02:00
Standard Layout Blueprint (Normalfall)
======================================
The diagram below shows the default `layout=standard` with `header=true` and `qr=true`
(`qrfirst` variant: QR on the left, text on the right):
![Standard layout blueprint](screenshots/layout-standard.svg)
What Influences What (Standard Layout)
--------------------------------------
- `paperwidth/paperheight/contentwidth/contentheight/padding`: define the outer geometry of the whole card.
- `header/noheader`: enables/disables the complete top block (name/logo/company line + separator line).
2026-04-30 19:43:03 +02:00
- `headeremphasis=person|company|balanced`: controls relative visual weight in the header (`person`: name larger, `company`: company line larger, `balanced`: same size).
2026-04-30 18:46:28 +02:00
- `logo` + `logoheight`: affects header composition and reserved vertical space.
- `company[height=...]` / `companylogo[height=...]`: affects second header line and reserved space.
- `textwidth` and `qrwidth`: define horizontal split of body columns.
- `qr/noqr`: removes the QR column; text then uses full body width.
- `qrfirst/textfirst`: swaps left/right order of QR and text columns.
- `icon/noicon`, `hint/nohint`, `iconleft/iconright`, `fill/nofill`: only affect formatting inside text lines.
- address field presence/visibility: controls whether address block (and map-pin icon) is rendered.
- `pgpfingerprint`: adds an extra footer line and reserves additional vertical space.
- `background`/`bgscale`/`bgopacity`: visual background only, no content reflow.
- `qrlogo`/`qreclevel`/`qrlogoscale`/`qrlogoborder`: QR internals only, no column reflow.
2026-04-30 17:34:16 +02:00
Data Definitions
================
Define data via commands like:
```latex
2018-08-14 23:10:09 +02:00
\email{name@example.com}
2026-04-30 17:34:16 +02:00
```
2018-08-14 23:10:09 +02:00
2026-04-30 17:34:16 +02:00
All data commands support optional `[hide]` (or `[hide=true]`): value remains in QR/vCard but is hidden in printed text.
```latex
\email[hide]{secret@example.com}
2018-08-14 23:10:09 +02:00
```
2026-04-30 17:34:16 +02:00
Recognized Commands
===================
2018-08-14 23:10:09 +02:00
2026-04-30 17:34:16 +02:00
### Name and Identity
2018-08-14 23:10:09 +02:00
2026-04-30 17:34:16 +02:00
- `\type`: `home` or `work` (used in ADR/TEL/EMAIL vCard typing)
- `\honoricprefix`: name prefix/title
- `\givennames`: given names
- `\additionalnames`: additional/middle names
- `\familynames`: family names
- `\honoricsuffix`: name suffix
- `\title`: position/job title (also contributes to displayed/vCard full name)
- `\role`: role/function
- `\company[logo=...,height=...,hide]`: company text with optional inline logo configuration
2018-08-14 23:10:09 +02:00
2026-04-30 17:34:16 +02:00
### Address
- `\pobox`
- `\extaddr`
- `\street`
- `\city`
- `\region`
- `\zip`
- `\country`
### Contact
- `\phone`
- `\email`
- `\jabber`
- `\matrixorg`
- `\cloud`
### Web and Social
- `\homepage`
- `\world`
- `\link`
- `\wordpress`
- `\drupal`
- `\joomla`
- `\wikipedia`
- `\git`
- `\gitea`
- `\github`
- `\facebook`
- `\twitter`
- `\youtube`
- `\google`
### Crypto
- `\pgpurl`
- `\pgpfingerprint`
### Visual Content
- `\logo[height=...]{content}`: logo near name (file path or TeX content)
- `\qrlogo[scale=...,opacity=...]{content}`: logo in QR center (file path or TeX content)
- `\background[scale=...,opacity=...]{file-or-color}`: background image or color
- `\centercontent{...}`: custom content used by `layout=centered`
- `\companylogo[height=...]{content}`: backward-compatible company logo helper
### Multi-Page and State Control
- `\clearfield{<name>}`: remove one field (printed + QR/vCard)
- `\clearcard`: remove all card fields plus card-scoped visuals (`\title`, logo, QR logo, background)
- `\clear{<name>}`: alias of `\clearfield{<name>}` (when no other package already defines `\clear`)
- `\newcard`: alias of `\newpage` + `\clearcard`
- empty structured entries are omitted automatically: if no personal-name parts remain, `N`/`FN` are not emitted; if no address parts remain, `ADR` is not emitted and the address icon/text block is hidden
- `\cardsetup{key=value,...}`: set layout options at runtime
- `\drawcard[key=value,...]`: draw a card and optionally adjust layout options inline
- `\setoption{key}{value}`: generic runtime setter
### Command-Style Setters for Layout Options
- geometry: `\setpaperwidth`, `\setpaperheight`, `\setcontentwidth`, `\setcontentheight`, `\setpadding`, `\setcutdist`, `\setcutlen`
2026-04-30 19:43:03 +02:00
- layout/typography: `\setfontsize`, `\settextwidth`, `\setqrwidth`, `\setqreclevel`, `\setqrlogoscale`, `\setqrlogoborder`, `\setlogoheight`, `\setlayout`, `\setheaderemphasis`
2026-04-30 17:34:16 +02:00
- booleans (`true`/`false`): `\setcrlf`, `\setaddress`, `\sethint`, `\seticon`, `\setrightalign`, `\seticonleft`, `\setfill`, `\setqrfirst`, `\setheader`, `\setqr`, `\sethttps`
- colors/language/format: `\setlang`, `\setcardcolor`, `\setqrcolor`, `\setcountryformat`, `\setbgscale`, `\setbgopacity`, `\setqrbgopacity`
- convenience toggles: `\noheader`, `\withheader`, `\noqr`, `\withqr`, `\standardlayout`, `\centeredlayout`
### Document Title Interop
- `\title{...}` is repurposed by this class for card position/title content
- `\carddocumenttitle{...}` calls the original LaTeX document-title command if needed
Second Page (Front/Back)
========================
Use one source file for front/back variants:
```latex
\begin{document}
% Page 1
\type{home}
\givennames{John}
\familynames{Doe}
\email{name@example.com}
\drawcard
% Page 2
\newcard
\type{work}
\company{My\ Company\ LTD}
\title{CEO}
\email{doe@mycompany.ltd}
\drawcard
\end{document}
```
2025-11-11 10:53:12 +01:00
2026-04-30 17:34:16 +02:00
Alternative: centered back side without QR and without header:
2025-11-11 10:53:12 +01:00
2026-04-30 17:34:16 +02:00
```latex
\newcard
\centercontent{{\Large\bfseries My\ Company\ LTD}\par\vspace{0.8em}hello@mycompany.ltd\par mycompany.ltd}
\drawcard[layout=centered,noqr,noheader]
```
2025-11-08 17:09:38 +01:00
2026-04-30 18:46:28 +02:00
Complete working example: [centered-backside-example.tex](examples/centered-backside-example.tex)
2026-04-30 17:34:16 +02:00
Equivalent using setter commands:
2025-11-08 17:09:38 +01:00
```latex
2026-04-30 17:34:16 +02:00
\newcard
\setlayout{centered}
\setqr{false}
\setheader{false}
\centercontent{{\Large\bfseries My\ Company\ LTD}\par\vspace{0.8em}hello@mycompany.ltd\par mycompany.ltd}
\drawcard
2025-11-08 17:09:38 +01:00
```
2026-04-30 19:43:03 +02:00
Header emphasis example:
```latex
\cardsetup{headeremphasis=company}
% or:
\setheaderemphasis{company}
% optional short alias:
\headeremphasis{balanced}
```
2026-04-30 17:34:16 +02:00
If you want to keep most data and only remove selected fields:
```latex
\newpage
\clear{givennames}
\clear{familynames}
\drawcard
```
See [john-doe-hongkong.tex](examples/john-doe-hongkong.tex) for a full two-page example.
Logo and Background Examples
============================
### Logo next to name
2025-11-08 17:09:38 +01:00
```latex
\documentclass{businesscard-qrcode}
2025-11-09 11:17:49 +01:00
\logo{logo.png}
2025-11-08 17:09:38 +01:00
```
2026-04-30 17:34:16 +02:00
### Logo in QR center
2025-11-08 17:09:38 +01:00
```latex
2026-04-30 17:34:16 +02:00
\documentclass[qreclevel=H,qrlogoscale=0.25]{businesscard-qrcode}
\qrlogo[scale=0.25]{logo.png}
2025-11-08 17:09:38 +01:00
```
2026-04-30 17:34:16 +02:00
Important for QR-center logos:
- prefer `qreclevel=H`
- test scan quality with multiple apps/devices
- reduce `qrlogoscale` if decoding becomes unreliable
### Large logo next to name
2025-11-08 17:09:38 +01:00
```latex
2025-11-09 12:08:18 +01:00
\documentclass[logoheight=6em]{businesscard-qrcode}
2025-11-09 11:17:49 +01:00
\logo{logo.png}
```
2026-04-30 17:34:16 +02:00
### Background color
```latex
\documentclass{businesscard-qrcode}
\background{yellow!20}
```
2026-04-30 17:34:16 +02:00
### Background image
```latex
\documentclass[bgscale=1.5,bgopacity=0.3,qrbgopacity=1.0]{businesscard-qrcode}
2025-11-09 11:03:42 +01:00
\background{photo.png}
```
2026-04-30 17:34:16 +02:00
Print the Card
==============
The default print format is `89mm × 59mm` with `2mm` border/cut distance (inner card: `85mm × 55mm`).
Example for `10cm × 5cm` card with `2mm` cut:
```latex
\documentclass[paperheight=5.4cm,paperwidth=10.4cm,
contentheight=5cm,contentwidth=10cm,
cutdist=2]{businesscard-qrcode}
```
![example with special paper size](screenshots/special-papersize.png)
Before printing, validate QR readability (phone app + command line, e.g. `zbarimg businesscard.pdf`).
2018-08-14 23:10:09 +02:00
Need More
=========
2026-04-30 17:34:16 +02:00
If you are missing a feature or configuration option, consult [project] and open a [ticket]. Contributions are welcome ([lgpl]).
2018-08-14 23:10:09 +02:00
[examples]: examples "more examples"
[vcard]: https://tools.ietf.org/html/rfc6350 "RFC 6350, vCard Format Specification Version 4.0"
[app]: https://f-droid.org/de/packages/com.google.zxing.client.android/ "Barcode Scanner"
[onlineprinters]: https://de.onlineprinters.ch/k/standardvisitenkarten "onlineprinters.ch"
[mschlenker]: https://gist.github.com/mschlenker/f60e0f15ff1edfc4881c "visitenkarten-qr.tex"
[texstudio_d30266.tex]: examples/texstudio_d30266.tex "simple example source file"
[texstudio_d30266.pdf]: examples/texstudio_d30266.pdf "simple example resulting pdf"
[example.tex]: examples/example.tex "larger example source file"
[example.pdf]: examples/example.pdf "larger example resulting pdf"
[jabber]: https://en.wikipedia.org/wiki/Jabber.org "the Jabber / XMPP instant messaging standard"
[matrix]: https://matrix.org "the matrix instant messaging standard"
[riot]: https://riot.im "matrix compatible instant messaging tool for all platforms"
[gitea]: https://gitea.io "github-like project repository, a gogs clone"
[gogs]: https://gitea.io "github-like project repository"
[github]: https://github.com "a project repository"
[git]: https://git-scm.com "a distributed version control system"
[facebook]: https://facebook.com "a social website"
[twitter]: https://twitter.com "a social website"
[google+]: https://plus.google.com "a social website"
[youtube]: https://youtube.com "a video website"
[wikipedia]: https://wikipedia.org "the online encyclopedia"
[pgp]: https://en.wikipedia.org/wiki/Pretty_Good_Privacy "pretty good privacy — encryption standard"
[nextcloud federation id]: https://nextcloud.com/federation "share your cloud across others"
2018-08-15 23:21:17 +02:00
[I]: https://marc.wäckerlin.ch "Marc Wäckerlin"
[ticket]: https://mrw.sh/templates/businesscard-qrcode/issues "open issues and tickets for my LaTeX-templates project"
[author]: https://marc.wäckerlin.ch "Marc Wäckerlin"
[project]: https://mrw.sh/templates/businesscard-qrcode "the main project page"
2018-08-15 23:34:15 +02:00
[lgpl]: https://www.gnu.org/licenses/lgpl-3.0 "Library GNU Public License"