adapt logo height to number of lines

This commit is contained in:
Marc Wäckerlin
2025-11-09 12:08:18 +01:00
parent 7de41206fd
commit eaa40a3901
8 changed files with 12 additions and 9 deletions
+2 -2
View File
@@ -99,7 +99,7 @@ Layout options are set as options to the `\documentclass`, e.g.:
- `logoinqr` or `nologoinqr`: place logo in the center of the QR code (`logoinqr`) instead of next to the name, default: `nologoinqr`. **Requires `qreclevel=H` for reliable scanning**. - `logoinqr` or `nologoinqr`: place logo in the center of the QR code (`logoinqr`) instead of next to the name, default: `nologoinqr`. **Requires `qreclevel=H` for reliable scanning**.
- `qrlogoscale=`: logo size in QR code as fraction of QR width (1.0 = 100%), default: `0.25` (25% width). Recommended values: Level H: 0.25-0.3, Level Q: 0.2, Level M: 0.15, Level L: 0.1. Higher values may reduce scannability. - `qrlogoscale=`: logo size in QR code as fraction of QR width (1.0 = 100%), default: `0.25` (25% width). Recommended values: Level H: 0.25-0.3, Level Q: 0.2, Level M: 0.15, Level L: 0.1. Higher values may reduce scannability.
- `qrlogoborder=`: transparent padding around logo in QR code as fraction of QR width (1.0 = 100%), default: `0.02` (2%). Adds space between logo and QR modules. - `qrlogoborder=`: transparent padding around logo in QR code as fraction of QR width (1.0 = 100%), default: `0.02` (2%). Adds space between logo and QR modules.
- `logoscale=`: scale factor for logo next to name (1.0 = 100% of name height), default: `1.0`. Use values like `2.0` or `2.5` for larger logos. - `logoheight=`: logo height next to name with unit (e.g., `4em`, `6em`), default: `4em` if company is set, `2em` otherwise.
- `bgscale=`: background image scale factor (1.0 = 100% of card height), default: `1.0`. Use values like `1.5` or `2.0` for zoomed/cropped backgrounds. Only affects images, not colors. - `bgscale=`: background image scale factor (1.0 = 100% of card height), default: `1.0`. Use values like `1.5` or `2.0` for zoomed/cropped backgrounds. Only affects images, not colors.
- `bgopacity=`: background image opacity/transparency (1.0 = 100% visible, 0.0 = invisible), default: `1.0`. Use lower values like `0.2` or `0.3` to fade the background so text remains readable. Only affects images, not colors. - `bgopacity=`: background image opacity/transparency (1.0 = 100% visible, 0.0 = invisible), default: `1.0`. Use lower values like `0.2` or `0.3` to fade the background so text remains readable. Only affects images, not colors.
- `qrbgopacity=`: QR code background opacity (1.0 = solid white, 0.0 = transparent), default: `1.0`. White background behind QR code ensures scannability over background images. Use `0.0` for no background or lower values like `0.8` for semi-transparent. - `qrbgopacity=`: QR code background opacity (1.0 = solid white, 0.0 = transparent), default: `1.0`. White background behind QR code ensures scannability over background images. Use `0.0` for no background or lower values like `0.8` for semi-transparent.
@@ -240,7 +240,7 @@ You can add an optional logo that appears next to the name or in the center of t
**Large logo next to name:** **Large logo next to name:**
```latex ```latex
\documentclass[logoscale=2.5]{businesscard-qrcode} \documentclass[logoheight=6em]{businesscard-qrcode}
\logo{logo.png} \logo{logo.png}
``` ```
+8 -5
View File
@@ -23,7 +23,7 @@
\DeclareStringOption[Q]{qreclevel} % QR code error correction level (L,M,Q,H) default Q \DeclareStringOption[Q]{qreclevel} % QR code error correction level (L,M,Q,H) default Q
\DeclareStringOption[0.25]{qrlogoscale} % logo size in QR code as fraction of QR width (1.0 = 100%), default 0.25 \DeclareStringOption[0.25]{qrlogoscale} % logo size in QR code as fraction of QR width (1.0 = 100%), default 0.25
\DeclareStringOption[0.02]{qrlogoborder} % white padding around logo in QR as fraction of QR width (1.0 = 100%), default 0.02 \DeclareStringOption[0.02]{qrlogoborder} % white padding around logo in QR as fraction of QR width (1.0 = 100%), default 0.02
\DeclareStringOption[1.0]{logoscale} % scale factor for logo next to name (1.0 = 100% name height), default 1.0 \DeclareStringOption{logoheight} % logo height next to name (with unit, e.g., 4em), default: 4em if company set, 2em otherwise
\DeclareStringOption[1.0]{bgscale} % background image scale (1.0 = 100% card height), default 1.0 \DeclareStringOption[1.0]{bgscale} % background image scale (1.0 = 100% card height), default 1.0
\DeclareStringOption[1.0]{bgopacity} % background image opacity (1.0 = 100% visible, 0.0 = invisible), default 1.0 \DeclareStringOption[1.0]{bgopacity} % background image opacity (1.0 = 100% visible, 0.0 = invisible), default 1.0
\DeclareStringOption[1.0]{qrbgopacity} % QR code background opacity (1.0 = white solid, 0.0 = transparent), default 1.0 \DeclareStringOption[1.0]{qrbgopacity} % QR code background opacity (1.0 = white solid, 0.0 = transparent), default 1.0
@@ -328,6 +328,10 @@ END:VCARD\BCQ@nl}
\newcommand\insertname{ \newcommand\insertname{
% typeset name into box for measurement % typeset name into box for measurement
\sbox{\BCQ@namebox}{\bfseries\cond{name}\ifexists{Xcompany}{\ifcsempty{name}{} { }\Xcompany}}% \sbox{\BCQ@namebox}{\bfseries\cond{name}\ifexists{Xcompany}{\ifcsempty{name}{} { }\Xcompany}}%
% Set default logoheight if not specified: 4em with company, 2em without
\ifx\BCQ@logoheight\@empty
\ifcsdef{Xcompany}{\def\BCQ@logoheight{4em}}{\def\BCQ@logoheight{2em}}%
\fi
\ifcsdef{Xlogo}{% logo defined \ifcsdef{Xlogo}{% logo defined
\ifBCQ@logoinqr \ifBCQ@logoinqr
% Logo in QR code: show name only % Logo in QR code: show name only
@@ -335,13 +339,12 @@ END:VCARD\BCQ@nl}
\ifexists{Xcompany}{\\\Xcompany}% \ifexists{Xcompany}{\\\Xcompany}%
\else \else
% Logo next to name: two-column layout (logo | name) % Logo next to name: two-column layout (logo | name)
% logoscale: 1.0 = 100% name height (default), 2.0 = 200%, etc.
\begin{minipage}{\textwidth} \begin{minipage}{\textwidth}
\begin{minipage}[c]{0.30\textwidth}% logo column (increased from 0.22) \begin{minipage}[c]{0.30\textwidth}% logo column
\includegraphics[height=\fpeval{\BCQ@logoscale}\dimexpr\ht\BCQ@namebox+\dp\BCQ@namebox\relax]{\Xlogo}% scaled to logoscale * name height \includegraphics[height=\BCQ@logoheight]{\Xlogo}%
\end{minipage} \end{minipage}
\hfill \hfill
\begin{minipage}[c]{0.67\textwidth}% name column (adjusted from 0.75) \begin{minipage}[c]{0.67\textwidth}% name column
\ifBCQ@rightalign\raggedleft\fi% apply alignment \ifBCQ@rightalign\raggedleft\fi% apply alignment
{\bfseries\cond{name}}% {\bfseries\cond{name}}%
\ifexists{Xcompany}{\\\Xcompany}% \ifexists{Xcompany}{\\\Xcompany}%
Binary file not shown.
+1 -1
View File
@@ -1,5 +1,5 @@
% !TeX program = xelatex % !TeX program = xelatex
\documentclass[bgscale=1.2,bgopacity=0.6,qrbgopacity=0.8,logoscale=4]{businesscard-qrcode} \documentclass[bgscale=1.2,bgopacity=0.6,qrbgopacity=0.8]{businesscard-qrcode}
\type{home} \type{home}
\givennames{Petra} \givennames{Petra}
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -1,4 +1,4 @@
\documentclass[bgscale=1.2,bgopacity=0.6,qrbgopacity=0.8,logoscale=4]{businesscard-qrcode} \documentclass[bgscale=1.2,bgopacity=0.6,qrbgopacity=0.8,logoheight=8em]{businesscard-qrcode}
\type{home} \type{home}
\givennames{Max} \givennames{Max}