original name support

This commit is contained in:
Olaf
2026-07-02 01:09:58 +02:00
parent f175c58730
commit 3ac26ec1df
4 changed files with 37 additions and 10 deletions
+5 -4
View File
@@ -1,6 +1,6 @@
# foldable-namecard
A LaTeX package for printing A4 foldable namecards with a name, country, and logo.
A LaTeX package for printing A4 foldable namecards with a name, optional second line, country, and logo.
## Requirements
@@ -95,14 +95,14 @@ If any font is missing, the package will attempt to use fallbacks or emit a warn
\end{document}
```
The CSV file must contain one `name,country` pair per line. Blank lines are skipped.
The CSV file may contain either two fields or three fields per line. With two fields, the package treats them as `name,country`. With three fields, it treats them as `name,subtitle,country`, printing the middle field underneath the name. Blank lines are skipped.
The package supports international characters including accented Latin letters and Chinese characters.
```
Alex Johnson,Sweden
Mina Patel,India
Mina Patel,Product Design,India
Sofia Garcia,Spain
Valgerður Ólafsdóttir,Iceland
Valgerður Ólafsdóttir,Engineering,Iceland
李明 (Lǐ Míng),China
王芳,中国
```
@@ -112,6 +112,7 @@ Valgerður Ólafsdóttir,Iceland
| Key | Default | Description |
|----------------|--------------|------------------------------------------|
| `name` | `Your Name` | Name printed on the card |
| `subtitle` | *(none)* | Optional line printed under the name |
| `country` | `Country` | Country printed below the name |
| `logo` | *(none)* | Path to logo image file |
| `logowidth` | `2cm` | Width of the logo |
BIN
View File
Binary file not shown.
+29 -4
View File
@@ -57,6 +57,7 @@
\newsavebox{\NC@namebox}
\newcommand\NC@name{Your Name}
\newcommand\NC@subtitle{}
\newcommand\NC@country{Country}
\newcommand\NC@logo{}
\newlength\NC@logoheight
@@ -68,6 +69,7 @@
\setlength\NC@logowidth{2cm}
\define@key{NC}{name}{\renewcommand\NC@name{#1}}
\define@key{NC}{subtitle}{\renewcommand\NC@subtitle{#1}}
\define@key{NC}{country}{\renewcommand\NC@country{#1}}
\define@key{NC}{logo}{\renewcommand\NC@logo{#1}}
\define@key{NC}{logoheight}{\setlength\NC@logoheight{#1}}
@@ -111,12 +113,26 @@
\savebox{\NC@namebox}{%
\resizebox{0.95\linewidth}{!}{\bfseries\ifx\NC@namefont\relax\NC@name\else{\NC@namefont\NC@name}\fi}%
}%
% If height > 4cm, scale down to 4cm; otherwise use 25cm version
\ifdim\ht\NC@namebox>4cm
{\NC@dbgbox{\makebox[0.95\linewidth][c]{\resizebox{!}{4cm}{\bfseries\ifx\NC@namefont\relax\NC@name\else{\NC@namefont\NC@name}\fi}}}}%
% If height > 3.5cm, scale down to 3cm; otherwise use 0.95\linewidth version
\ifdim\ht\NC@namebox>3.5cm
{\NC@dbgbox{\makebox[0.95\linewidth][c]{\resizebox{!}{3.cm}{\bfseries\ifx\NC@namefont\relax\NC@name\else{\NC@namefont\NC@name}\fi}}}}%
\else
{\NC@dbgbox{\makebox[0.95\linewidth][c]{\usebox{\NC@namebox}}}}%
\fi\par
\ifx\NC@subtitle\@empty\else
\savebox{\NC@namebox}{%
\resizebox{0.95\linewidth}{!}{\bfseries\ifx\NC@namefont\relax\NC@subtitle\else{\NC@namefont\NC@subtitle}\fi}%
}%
\vspace{2mm}
\ifdim\ht\NC@namebox>2cm
{\NC@dbgbox{\makebox[0.95\linewidth][c]{\resizebox{!}{2cm}{\bfseries\ifx\NC@namefont\relax\NC@subtitle\else{\NC@namefont\NC@subtitle}\fi}}}}%
\else
{\NC@dbgbox{\makebox[0.95\linewidth][c]{\usebox{\NC@namebox}}}}%
\fi\par
\fi
\vspace{5mm}
{\NC@dbgbox{\makebox[0.9\linewidth][c]{\resizebox{!}{7.5mm}{\large \NC@country}}}\par}
\end{minipage}%
@@ -139,8 +155,17 @@
\tl_trim_spaces:N \l_tmpa_tl
\seq_pop_left:NN \l_nc_fields_seq \l_tmpb_tl
\tl_trim_spaces:N \l_tmpb_tl
\seq_if_empty:NTF \l_nc_fields_seq
{
\typeout{===\ Printing\ namecard:\ \l_tmpa_tl,\ \l_tmpb_tl\ ===}
\namecardsetup{name=\l_tmpa_tl,country=\l_tmpb_tl}
\namecardsetup{name=\l_tmpa_tl,subtitle=,country=\l_tmpb_tl}
}
{
\seq_pop_left:NN \l_nc_fields_seq \l_tmpc_tl
\tl_trim_spaces:N \l_tmpc_tl
\typeout{===\ Printing\ namecard:\ \l_tmpa_tl,\ \l_tmpb_tl,\ \l_tmpc_tl\ ===}
\namecardsetup{name=\l_tmpa_tl,subtitle=\l_tmpb_tl,country=\l_tmpc_tl}
}
\NC@renderpage
\newpage
}
+2 -1
View File
@@ -3,6 +3,7 @@ Mina Patel,India
Sofia Garcia,Spain
Jan van den Heuvel tot Beichlingen, Netherlands
Valgerður Ólafsdóttir, Iceland
李明 (Lǐ Míng), China
Lǐ Míng,李明 , China
王芳,中国
O.K., NL
Myrryam Haddar,مريم حدار , Egypt
1 Alex Johnson Alex Johnson,Sweden Sweden
3 Sofia Garcia Sofia Garcia,Spain Spain
4 Jan van den Heuvel tot Beichlingen Jan van den Heuvel tot Beichlingen, Netherlands Netherlands
5 Valgerður Ólafsdóttir Valgerður Ólafsdóttir, Iceland Iceland
6 李明 (Lǐ Míng) Lǐ Míng,李明 , China China
7 王芳 王芳,中国 中国
8 O.K. O.K., NL NL
9 Myrryam Haddar,مريم حدار , Egypt