Dynamic Logo Counter

This commit is contained in:
Frederik Beimgraben 2024-11-18 00:04:25 +00:00
parent 349a7e9c22
commit 80698b3f16
5 changed files with 93 additions and 45 deletions

View File

@ -41,7 +41,6 @@
%---------------------------------------- %----------------------------------------
\RequirePackage[ngerman]{babel} \RequirePackage[ngerman]{babel}
\RequirePackage{lmodern} \RequirePackage{lmodern}
\RequirePackage{amsmath}
\RequirePackage{graphicx} \RequirePackage{graphicx}
\RequirePackage{svg} \RequirePackage{svg}
\RequirePackage[T1]{fontenc} \RequirePackage[T1]{fontenc}
@ -50,6 +49,9 @@
\RequirePackage{fancyhdr} \RequirePackage{fancyhdr}
\RequirePackage{bophook} \RequirePackage{bophook}
\RequirePackage{ifthen} \RequirePackage{ifthen}
\RequirePackage{arrayjobx}
\RequirePackage{etoolbox}
\RequirePackage{transparent}
%---------------------------------------- %----------------------------------------
% REFS % REFS
@ -123,57 +125,43 @@
%---------------------------------------- %----------------------------------------
% ==== Add more logos to be placed besides the main logo on the title page ==== % ==== Add more logos to be placed besides the main logo on the title page ====
\newcommand{\titlePageLogosArray}{}
\newcommand{\footerLogosArray}{}
\newcommand{\logosScale}{1} \newcommand{\logosScale}{1}
\newcommand{\mainLogoScale}{1} \newcommand{\mainLogoScale}{1}
\newlength{\imageHeight} \newlength{\imageHeight}
\newcounter{logoCounter}
\setcounter{logoCounter}{1}
\DeclareRobustCommand{\SetLogosScale}[1]{ \DeclareRobustCommand{\SetLogosScale}[1]{
\renewcommand{\logosScale}{#1} \renewcommand{\logosScale}{#1}
} }
\DeclareRobustCommand{\AddLogo}[5]{ \let\newglobalarray\newarray
\appto{\titlePageLogosArray}{ \patchcmd{\newglobalarray}{\edef}{\xdef}{}{}
\node[anchor=west, xshift=0.5cm] (logo#4) at (logo#5.east) {
\setlength{\imageHeight}{1.5cm*\real{#2}*\real{\logosScale}}
\StrBehind{#1}{.}[\fileExtension]
\strcompare{\fileExtension}{svg}{
\includesvg[height=\imageHeight]{#1}
}{
\includegraphics[height=\imageHeight]{#1}
}
};
\filldraw[white, opacity=#3] (logo#4.north east) rectangle (logo#4.south west);
}
\appto{\footerLogosArray}{ % AddLogo Command with automatic counter
\node[anchor=east, xshift=-0.1cm] (logo#4) at (logo#5.west) { % Array to store the logos and to be used in pgffor later
\setlength{\imageHeight}{1.5cm*\real{#2}*\real{0.55}*\real{\logosScale}} \newglobalarray\LogosPaths
\StrBehind{#1}{.}[\fileExtension] \newglobalarray\LogosScales
\strcompare{\thepage}{1}{}{ \newglobalarray\LogosOpacities
\strcompare{\fileExtension}{svg}{ \newglobalarray\LogosExtensions
\includesvg[height=\imageHeight]{#1} \newcounter{logoCounter}
}{ \setcounter{logoCounter}{0}
\includegraphics[height=\imageHeight]{#1} \expandarrayelementtrue
} % Command to add a logo to the array
} % Usage: \AddLogoToArray{<Name>}{<Scale>}{<Opacity>}
}; \DeclareRobustCommand{\AddLogo}[4]{
\filldraw[white, opacity=#3] (logo#4.north east) rectangle (logo#4.south west); \stepcounter{logoCounter}
} \LogosPaths(\thelogoCounter)={#1}
\LogosScales(\thelogoCounter)={#2}
\LogosOpacities(\thelogoCounter)={#3}
\LogosExtensions(\thelogoCounter)={#4}
} }
\DeclareRobustCommand{\SetupTitlePageLogos}{ % Command to get opacity of a logo
\titlePageLogosArray \DeclareRobustCommand{\GetLogoOpacity}[1]{
\expand{\LogosOpacities(#1)}
} }
\DeclareRobustCommand{\SetupFooterLogos}{
\footerLogosArray
}
% ============================================================================= % =============================================================================
\def\skylinePath{TeX/Assets/Images/Skyline.svg} \def\skylinePath{TeX/Assets/Images/Skyline.svg}
@ -184,12 +172,42 @@
\AtBeginPage{ \AtBeginPage{
\setlength{\imageHeight}{2cm*\real{\mainLogoScale}*\real{\logosScale}*\real{0.45}} \setlength{\imageHeight}{2cm*\real{\mainLogoScale}*\real{\logosScale}*\real{0.45}}
\begin{tikzpicture}[overlay, remember picture] \begin{tikzpicture}[overlay, remember picture]
% === Main Logo(s) ===
\node[anchor=south east, inner sep=0pt, xshift=-\footerXShift, yshift=\footerYShift] (logo0) at (current page.south east) { \node[anchor=south east, inner sep=0pt, xshift=-\footerXShift, yshift=\footerYShift] (logo0) at (current page.south east) {
\strcompare{\thepage}{1}{}{ \strcompare{\thepage}{1}{}{
\includesvg[height=\imageHeight]{\imagesPath/DUMMY_FOOT.svg} \includesvg[height=\imageHeight]{\imagesPath/DUMMY_FOOT.svg}
} }
}; };
\SetupFooterLogos % For loop to place all logos
\foreach \i in {1,...,\value{logoCounter}} {
% Calculate name for i-1
\pgfmathtruncatemacro{\prev}{\i-1}
\node[anchor=east, inner sep=0pt, xshift=-0.1cm, opacity=0.3] (logo\i) at (logo\prev.west) {
\makeatletter
\testarray{LogosScales}(\i)
\setlength{\imageHeight}{1.5cm*\real{\temp@macro}*\real{\logosScale}*\real{0.55}}
\testarray{LogosExtensions}(\i)
\let\extension\temp@macro
\testarray{LogosOpacities}(\i)
\let\opacity\temp@macro
\testarray{LogosPaths}(\i)
\ifthenelse{\equal{\extension}{svg}}{
\begin{tikzpicture}
\node[opacity=\opacity] {
\includesvg[height=\imageHeight]{TeX/Assets/Images/\temp@macro.\extension}
};
\end{tikzpicture}
}{
\begin{tikzpicture}
\node[opacity=\opacity] {
\includegraphics[height=\imageHeight]{TeX/Assets/Images/\temp@macro.\extension}
};
\end{tikzpicture}
}
\makeatother
};
}
% Skyline
\node[anchor=south west, inner sep=0pt, yshift=0em] at (current page.south west) { \node[anchor=south west, inner sep=0pt, yshift=0em] at (current page.south west) {
\includesvg[width=1.5\paperwidth]{\skylinePath} \includesvg[width=1.5\paperwidth]{\skylinePath}
}; };

View File

@ -9,7 +9,34 @@
\node[anchor=north west, inner sep=0pt, xshift=1.8cm, yshift=-1.5cm, opacity=0] (logo0) at (current page.north west) { \node[anchor=north west, inner sep=0pt, xshift=1.8cm, yshift=-1.5cm, opacity=0] (logo0) at (current page.north west) {
\includesvg[height=\imageHeight]{\imagesPath/DUMMY_FOOT.svg} \includesvg[height=\imageHeight]{\imagesPath/DUMMY_FOOT.svg}
}; };
\SetupTitlePageLogos \foreach \i in {1,...,\value{logoCounter}} {
% Calculate name for i-1
\pgfmathtruncatemacro{\prev}{\i-1}
\node[anchor=west, inner sep=0pt, xshift=-0.1cm, opacity=0.3] (logo\i) at (logo\prev.east) {
\makeatletter
\testarray{LogosScales}(\i)
\setlength{\imageHeight}{1.5cm*\real{\temp@macro}*\real{\logosScale}}
\testarray{LogosExtensions}(\i)
\let\extension\temp@macro
\testarray{LogosOpacities}(\i)
\let\opacity\temp@macro
\testarray{LogosPaths}(\i)
\ifthenelse{\equal{\extension}{svg}}{
\begin{tikzpicture}
\node[opacity=\opacity] {
\includesvg[height=\imageHeight]{TeX/Assets/Images/\temp@macro.\extension}
};
\end{tikzpicture}
}{
\begin{tikzpicture}
\node[opacity=\opacity] {
\includegraphics[height=\imageHeight]{TeX/Assets/Images/\temp@macro.\extension}
};
\end{tikzpicture}
}
\makeatother
};
}
\end{tikzpicture} \end{tikzpicture}
\vskip 10em \vskip 10em

View File

@ -153,12 +153,15 @@
% Pie Chart % Pie Chart
\usepackage{pgf-pie} \usepackage{pgf-pie}
% Transparent images
\usepackage{transparent}
% ==== /Imports ==== % ==== /Imports ====
% Tool to import relative to current file using % Tool to import relative to current file using
% the currfile package % the currfile package
\DeclareRobustCommand{\inputrelative}[1]{ \DeclareRobustCommand{\inputrelative}[1]{
% Write \currfiledir#1 to the log file % Write \currfiledir#1 to the log file
\typeout{Importing file: <\currfiledir>} \typeout{Importing file: <\currfiledir#1> relative to <\currfiledir>}
\input{\currfiledir#1} \input{\currfiledir#1}
} }

View File

@ -7,5 +7,5 @@
\title{Handout zur außerordentlichen STUPA-Sitzung am \meetingDate} \title{Handout zur außerordentlichen STUPA-Sitzung am \meetingDate}
\AddLogo{TeX/Assets/Images/STUPA.png}{1.1}{0.3}{1}{0} \AddLogoExplicit{TeX/Assets/Images/STUPA.png}{1.1}{0.3}{1}{0}
\AddLogo{TeX/Assets/Images/HSRT.png}{1.4}{0.0}{2}{1} \AddLogoExplicit{TeX/Assets/Images/HSRT.png}{1.4}{0.0}{2}{1}

View File

@ -3,10 +3,10 @@
%%%% ORDER IS CRITICAL %%%% %%%% ORDER IS CRITICAL %%%%
% STUPA Logo % STUPA Logo
%\AddLogo{TeX/Assets/Images/STUPA.png}{1.1}{0.3}{1}{0} \AddLogo{STUPA}{1.1}{0.7}{png}
% HSRT Logo % HSRT Logo
\AddLogo{TeX/Assets/Images/HSRT.png}{1.4}{0.0}{1}{0} \AddLogo{HSRT}{1.4}{1.0}{png}
% METI Logo % METI Logo
% \AddLogo{TeX/Assets/Images/METI.png}{1.1}{0.3}{3}{2} \AddLogo{METI}{1.1}{0.5}{png}