diff --git a/README.md b/README.md index 23dfae0..c92c055 100644 --- a/README.md +++ b/README.md @@ -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 | diff --git a/example.pdf b/example.pdf index 5ef0ec9..8ee6bad 100644 Binary files a/example.pdf and b/example.pdf differ diff --git a/foldable-namecard.sty b/foldable-namecard.sty index e2ef193..bef23fe 100644 --- a/foldable-namecard.sty +++ b/foldable-namecard.sty @@ -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 - \typeout{===\ Printing\ namecard:\ \l_tmpa_tl,\ \l_tmpb_tl\ ===} - \namecardsetup{name=\l_tmpa_tl,country=\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,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 } diff --git a/names.csv b/names.csv index 2020800..31b71cc 100644 --- a/names.csv +++ b/names.csv @@ -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