country with city if short

This commit is contained in:
Marc Wäckerlin
2025-11-08 19:11:43 +01:00
parent 0f802a02a8
commit 407c7eed2d
6 changed files with 54 additions and 4 deletions
+36 -3
View File
@@ -42,6 +42,7 @@
\DeclareComplementaryOption{textfirst}{qrfirst}
\DeclareBoolOption[true]{https}
\DeclareComplementaryOption{www}{https}
\DeclareStringOption[auto]{countryformat} % auto: <4 chars inline with mdash, >=4 separate line; inline: always inline; below: always separate line
\DeclareDefaultOption{\@unknownoptionerror}
\ProcessKeyvalOptions*
@@ -68,6 +69,7 @@
\RequirePackage{fontawesome}
\RequirePackage[final]{qrcode}
\RequirePackage{etoolbox}
\RequirePackage{xstring} % for string length checking
\RequirePackage{DejaVuSans}
\RequirePackage[T1]{fontenc}
\RequirePackage{wrapfig}
@@ -145,7 +147,6 @@
\newcommand\cond[1]{\ifcsdef{#1}{\exec{#1}}{}}
\newcommand\heightscale{\dimexpr\textheight-\ifcsempty{name}{0em}{2em}-\ifcsdef{Xpgpfingerprint}{2em}{0em}-\ifcsdef{Xadditionalnames}{2em}{0em}\relax}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% name - assemble full name from the parts, such as Xgivennames and Xfamilynames
\newcommand\name{\ifexists{Xhonoricprefix}{\Xhonoricprefix\ }\ifexists{Xgivennames}{\Xgivennames\ }\ifexists{Xfamilynames}{\Xfamilynames}\ifexists{Xhonoricsuffix}{\ \Xhonoricsuffix}}
@@ -192,6 +193,38 @@ FN:\name\ifexists{Xadditionalnames}{\ifcsempty{name}{} { }\Xadditionalnames}\BCQ
END:VCARD\BCQ@nl}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% formatcountry - format country based on length and options
\newcommand\formatcountry{%
\ifcsdef{Xcountry}{%
\def\BCQ@shouldinline{false}%
% Check countryformat option
\ifdefstring{\BCQ@countryformat}{inline}{%
\def\BCQ@shouldinline{true}%
}{%
\ifdefstring{\BCQ@countryformat}{below}{%
\def\BCQ@shouldinline{false}%
}{%
% auto mode: check length
\StrLen{\Xcountry}[\BCQ@countrylen]%
\ifnum\BCQ@countrylen<4\relax%
% Short country code AND city/zip exists inline
\ifboolexpr{test {\ifcsdef{Xcity}} or test {\ifcsdef{Xzip}}}{%
\def\BCQ@shouldinline{true}%
}{}%
\fi%
}%
}%
% Output country
\ifdefstring{\BCQ@shouldinline}{true}{%
\Xcountry\ \textemdash\ %
}{%
\Xcountry
}%
}{}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% address - the address as shown in the textbox
\newcommand\address{
@@ -202,9 +235,9 @@ END:VCARD\BCQ@nl}
\cond{Xstreet}
\cond{Xzip} \cond{Xcity}
\formatcountry\cond{Xzip} \cond{Xcity}
\cond{Xregion} \cond{Xcountry}
\cond{Xregion}
}