Search code examples
latextitletabular

Custom titlepage in LaTeX


I am trying to create a custom title page in LaTeX according to my organization's template (in Word).

I managed to get close to it with the following code:

\documentclass{report}
\usepackage[a4paper,twoside,bindingoffset=0cm,nomarginpar,includeheadfoot,headheight=1.25cm,headsep=0cm,top=1cm,bottom=1.8cm,inner=1.75cm,outer=1.75cm,showframe]{geometry}
\usepackage{xcolor}
\usepackage{colortbl}
\usepackage{calc}
\usepackage{graphicx}
\usepackage{tabularx}
\definecolor{greenBE}{RGB}{141,182,60}
\definecolor{blueBE}{RGB}{0,111,144}

\title{La qualité de l'air en Région de Bruxelles-Capitale}
\newcommand{\subtitle}{Rapport annuel 2019}
\author{}

\usepackage{lipsum}

\begin{document}

\makeatletter
\begin{titlepage}
\thispagestyle{empty}
\newlength{\rulewidth}\setlength{\rulewidth}{3cm}%
\newlength{\logowidth}\setlength{\logowidth}{2.5cm}%
\newlength{\logoheight}\setlength{\logoheight}{\logowidth*\ratio{592pt}{1538pt}}% image size : 1538 x 592
\begingroup
\setlength{\tabcolsep}{0pt}
\renewcommand{\arraystretch}{0}
\noindent%
\begin{tabularx}{\textwidth}{p{\rulewidth}c>{\centering}X}
\cellcolor{blueBE}&\includegraphics[width=\logowidth]{ILLU_FR_LogoBE.jpg}&\cellcolor{greenBE}\color{white}{RAPPORT TECHNIQUE}
\end{tabularx}
\endgroup

\vspace*{3cm}

\color{blueBE}
\raggedleft\MakeUppercase{\Large\textbf{\@title}}\\
~\\
\raggedleft\large\textbf{\subtitle}

\vfill

\raggedleft\MakeUppercase{\Large\@date}\\

\vspace*{4cm}

\noindent%
\color{blueBE}{\rule{\textwidth}{\logoheight}}
\end{titlepage}
\makeatother
\restoregeometry

\tableofcontents

\chapter{Prerequisites}\label{prerequisites}

\lipsum

\end{document}

and the image logo ILLU_FR_LogoBE.jpgenter image description here

However, as you can notice below, the text "RAPPORT TECHNIQUE" on top of the first page is enlarging the height of the row. Instead, I would like to center it vertically in the middle of the logo.

What am I doing wrong ?

Many thanks,

Alessandro

enter image description here


Solution

  • You could use \usepackage[export]{adjustbox} and then play around with different valign options for the graphic.

    \documentclass{report}
    \usepackage[a4paper,twoside,bindingoffset=0cm,nomarginpar,includeheadfoot,headheight=1.25cm,headsep=0cm,top=1cm,bottom=1.8cm,inner=1.75cm,outer=1.75cm,showframe]{geometry}
    \usepackage{xcolor}
    \usepackage{colortbl}
    \usepackage{calc}
    \usepackage{graphicx}
    \usepackage{tabularx}
    \definecolor{greenBE}{RGB}{141,182,60}
    \definecolor{blueBE}{RGB}{0,111,144}
    
    \title{La qualité de l'air en Région de Bruxelles-Capitale}
    \newcommand{\subtitle}{Rapport annuel 2019}
    \author{}
    
    \usepackage{lipsum}
    
    \usepackage[export]{adjustbox}
    
    \begin{document}
    
    \makeatletter
    \begin{titlepage}
    \thispagestyle{empty}
    \newlength{\rulewidth}\setlength{\rulewidth}{3cm}%
    \newlength{\logowidth}\setlength{\logowidth}{2.5cm}%
    \newlength{\logoheight}\setlength{\logoheight}{\logowidth*\ratio{592pt}{1538pt}}% image size : 1538 x 592
    \begingroup
    \setlength{\tabcolsep}{0pt}
    %\renewcommand{\arraystretch}{0}
    \noindent%
    \begin{tabularx}{\textwidth}{p{\rulewidth}c>{\centering}X}
    \cellcolor{blueBE}&\includegraphics[width=\logowidth,valign=t]{ILLU_FR_LogoBE.jpg}&\cellcolor{greenBE}\color{white}RAPPORT TECHNIQUE
    \end{tabularx}%
    \endgroup
    
    \vspace*{3cm}
    
    \color{blueBE}
    \raggedleft\MakeUppercase{\Large\textbf{\@title}}\\
    ~\\
    \raggedleft\large\textbf{\subtitle}
    
    \vfill
    
    \raggedleft\MakeUppercase{\Large\@date}\\
    
    \vspace*{4cm}
    
    \noindent%
    \color{blueBE}{\rule{\textwidth}{\logoheight}}
    \end{titlepage}
    \makeatother
    \restoregeometry
    
    \tableofcontents
    
    \chapter{Prerequisites}\label{prerequisites}
    
    \lipsum
    
    \end{document}
    

    enter image description here