fix display bug if no company is set; improve title width vs. logo wodthy

This commit is contained in:
Marc Wäckerlin
2025-11-10 14:00:34 +01:00
parent dd92e3c5df
commit d99e4d0872
+48 -20
View File
@@ -198,10 +198,15 @@
% internal boxes and lengths for measuring % internal boxes and lengths for measuring
\newsavebox{\BCQ@namebox} \newsavebox{\BCQ@namebox}
\newsavebox{\BCQ@logobox}
\newlength{\BCQ@logoheightdimen} \newlength{\BCQ@logoheightdimen}
\setlength{\BCQ@logoheightdimen}{0pt}% initialize to prevent errors \setlength{\BCQ@logoheightdimen}{0pt}% initialize to prevent errors
\newlength{\BCQ@reservedheight} \newlength{\BCQ@reservedheight}
\newlength{\BCQ@heightscale} \newlength{\BCQ@heightscale}
\newlength{\BCQ@namewidth}
\newlength{\BCQ@logosep}
\newlength{\BCQ@logosepused}
\setlength{\BCQ@logosep}{1em}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% name - assemble full name from the parts, such as Xgivennames and Xfamilynames % name - assemble full name from the parts, such as Xgivennames and Xfamilynames
@@ -212,12 +217,30 @@
\ifexists{Xfamilynames}{\Xfamilynames}% \ifexists{Xfamilynames}{\Xfamilynames}%
\ifexists{Xhonoricsuffix}{\ \Xhonoricsuffix}% \ifexists{Xhonoricsuffix}{\ \Xhonoricsuffix}%
} }
\newcommand\ifhaspersonalname[2]{%
\ifcsdef{Xhonoricprefix}{#1}{%
\ifcsdef{Xgivennames}{#1}{%
\ifcsdef{Xadditionalnames}{#1}{%
\ifcsdef{Xfamilynames}{#1}{%
\ifcsdef{Xhonoricsuffix}{#1}{#2}%
}%
}%
}%
}%
}
\newcommand\ifhasposition[2]{%
\ifcsdef{Xcompany}{#1}{%
\ifcsdef{Xtitle}{#1}{%
\ifcsdef{Xrole}{#1}{#2}%
}%
}%
}
% heightscale - calculate available height for text/QR % heightscale - calculate available height for text/QR
% Uses actual logo height if logo is taller than default reserved space % Uses actual logo height if logo is taller than default reserved space
% This is computed as a length and stored, not a macro % This is computed as a length and stored, not a macro
\newcommand\computeheightscale{% \newcommand\computeheightscale{%
\setlength{\BCQ@reservedheight}{\dimexpr\ifcsempty{personalname}{0em}{2em}+\ifcsdef{Xcompany}{2em}{0em}\relax}% \setlength{\BCQ@reservedheight}{\dimexpr\ifhaspersonalname{2em}{0em}+\ifhasposition{2em}{0em}\relax}%
\ifdim\BCQ@logoheightdimen>\BCQ@reservedheight \ifdim\BCQ@logoheightdimen>\BCQ@reservedheight
\setlength{\BCQ@heightscale}{\dimexpr\textheight-\BCQ@logoheightdimen-\ifcsdef{Xpgpfingerprint}{2em}{0em}\relax}% \setlength{\BCQ@heightscale}{\dimexpr\textheight-\BCQ@logoheightdimen-\ifcsdef{Xpgpfingerprint}{2em}{0em}\relax}%
\else \else
@@ -227,27 +250,24 @@
\newcommand\heightscale{\BCQ@heightscale} \newcommand\heightscale{\BCQ@heightscale}
\newcommand\companyrolestring{% \newcommand\companyrolestring{%
\ifcsdef{Xcompany}{% \ifcsdef{Xtitle}{\Xtitle}{}%
\ifcsdef{Xtitle}{%
\Xtitle%
\ifcsdef{Xrole}{, \Xrole}{}%
\ \Xcompany%
}{%
\ifcsdef{Xrole}{% \ifcsdef{Xrole}{%
\Xrole\ \Xcompany% \ifcsdef{Xtitle}{, }{}%
}{% \Xrole
\Xcompany% }{}%
}% \ifcsdef{Xcompany}{%
\ifcsdef{Xtitle}{\ \Xcompany}{%
\ifcsdef{Xrole}{\ \Xcompany}{\Xcompany}%
}% }%
}{}% }{}%
} }
\newcommand\name{% \newcommand\name{%
\personalname \personalname
\ifcsdef{Xcompany}{% \ifhasposition{%
\ifcsempty{personalname}{% \ifhaspersonalname{%
\companyrolestring
}{%
\ (\companyrolestring)% \ (\companyrolestring)%
}{%
\companyrolestring
}% }%
}{}% }{}%
} }
@@ -443,6 +463,7 @@ END:VCARD\BCQ@nl}
}% }%
% Store logo height as dimension for heightscale calculation % Store logo height as dimension for heightscale calculation
\ifcsdef{Xlogo}{% \ifcsdef{Xlogo}{%
\sbox{\BCQ@logobox}{\includegraphics[height=\BCQ@logoheight@used]{\Xlogo}}%
\setlength{\BCQ@logoheightdimen}{\BCQ@logoheight@used}% \setlength{\BCQ@logoheightdimen}{\BCQ@logoheight@used}%
}{% }{%
\setlength{\BCQ@logoheightdimen}{0pt}% \setlength{\BCQ@logoheightdimen}{0pt}%
@@ -450,13 +471,20 @@ END:VCARD\BCQ@nl}
% Compute heightscale after logo height is known % Compute heightscale after logo height is known
\computeheightscale \computeheightscale
\ifcsdef{Xlogo}{% logo defined \ifcsdef{Xlogo}{% logo defined
% Logo next to name: two-column layout (logo | name) % Logo next to name: dynamic columns (logo natural width, name uses remaining space)
\setlength{\BCQ@logosepused}{\BCQ@logosep}%
\setlength{\BCQ@namewidth}{\dimexpr\textwidth-\wd\BCQ@logobox-\BCQ@logosepused\relax}%
\ifdim\BCQ@namewidth<0pt
\setlength{\BCQ@logosepused}{0pt}%
\setlength{\BCQ@namewidth}{\dimexpr\textwidth-\wd\BCQ@logobox\relax}%
\ifdim\BCQ@namewidth<0pt\setlength{\BCQ@namewidth}{0pt}\fi
\fi
\begin{minipage}{\textwidth} \begin{minipage}{\textwidth}
\begin{minipage}[c]{0.30\textwidth}% logo column \begin{minipage}[c]{\wd\BCQ@logobox}% logo column
\includegraphics[height=\BCQ@logoheight@used]{\Xlogo}% \usebox{\BCQ@logobox}%
\end{minipage} \end{minipage}
\hfill \hspace{\BCQ@logosepused}
\begin{minipage}[c]{0.67\textwidth}% name column \begin{minipage}[c]{\BCQ@namewidth}% name column
\ifBCQ@rightalign\raggedleft\fi% apply alignment \ifBCQ@rightalign\raggedleft\fi% apply alignment
{\bfseries\cond{name}}% {\bfseries\cond{name}}%
% Optional company logo below name % Optional company logo below name