I am an educator in mathematics and prefer using LaTeX for typesetting documents. However, the dean of our faculty provided us with a Word version for creating exam headers. I tried to convert it to LaTeX as follows:
\documentclass[12pt,a4paper]{article}
\usepackage[latin1]{inputenc} % not needed in new latex versions
\usepackage[T1]{fontenc}
\usepackage{amsfonts,amsmath,amssymb,graphicx,amsthm,mathtools,systeme}
\usepackage[tikz]{bclogo}
\usepackage{tikz,tkz-tab,moreverb} % tableau de signe moreverb not needed
\usetikzlibrary{arrows}
%----------
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
\node[shape=circle,draw,inner sep=1pt] (char) {#1};}}
%----------
\usepackage[french]{babel}
\usepackage{pifont} %bouni
\usepackage{fancybox} %pour faire l'encadrement
\usepackage[usestackEOL]{stackengine}
\usepackage{verbatim}
\usepackage{color}
\usepackage[final]{pdfpages} %pour inserer une page pdf
\usepackage{awesomebox} %takecare
%---- Dimensions des marges ---
\usepackage{geometry}
\geometry{left=1.5cm,right=1.5cm,top=1.0cm,bottom=1.5cm}
%\usepackage{setspace}
%\onehalfspacing
%---- pages numbers with tikz---
\usepackage{fancyhdr}
\usepackage{lastpage}
\usetikzlibrary{shapes}
\fancypagestyle{mypagestyle}{%
\renewcommand{\headrulewidth}{0pt}
\fancyhf{}
\fancyfoot[C]{\tikz{ \node [rectangle, draw = black] (rectangle) at (0,0) {\thepage/\pageref{LastPage}} }}
}
\pagestyle{mypagestyle}
%----New Structure Exercice -----
\newtheoremstyle{sboxexc}% name of the style to be used
{\topsep}% measure of space to leave above the theorem. E.g.: 3pt
{\topsep}% measure of space to leave below the theorem. E.g.: 3pt
{\itshape}% name of font to use in the body of the theorem
{0pt}% of space to indent
{\bfseries}% name of head font
{}% punctuation between head and body
{ }% space after theorem head; " " = normal interword space
{\thmname{#1}}% Manually specify head
\newcounter{counter}
\setcounter{counter}{1}
\theoremstyle{sboxexc}
\newcommand{\optionaltext}{}
\newtheorem*{Exc}{\shadowbox{\ding{228} Exercice \arabic{counter}\optionaltext}}
\newcommand{\exo}[2][]{\renewcommand{\optionaltext}{#2}\begin{Exc}\normalfont\mbox{}\par}
\newcommand{\finexo}{\renewcommand{\optionaltext}{}\end{Exc}\addtocounter{counter}{1}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\isEquivTo}[1]{\underset{#1}{\sim}}
\newcommand*{\transp}[2][-3mu]{\ensuremath{\mskip1mu\prescript{\smash{\mathrm t\mkern#1}}{}{\mathstrut#2}}}%
\DeclareMathOperator{\im}{Im}
\DeclareMathOperator{\rg}{rg}
\DeclareMathOperator{\tr}{tr}
\DeclareMathOperator{\vect}{Vect}
\DeclareMathOperator{\mat}{Mat}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\definecolor{sfaxlogo}{RGB}{127,176,206}
\colorlet{sfaxblue}{sfaxlogo!70!black!60!blue}
%\pagestyle{empty}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%------------------------------------------------
\usepackage[column=0]{cellspace}
\setlength{\cellspacetoplimit}{10.4pt}
\setlength{\cellspacebottomlimit}{10.4pt}
%------------------------------------------------
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%begin entete%%%%%%%%%%%%%%%%%%%%%%%%%%%
{\scriptsize\bfseries \begin{tabular}{|@{}c@{}|c|@{}c@{}|}
\cline{1-1} \cline{3-3}
\begin{tabular}{c}
Ministère de l'Enseignement\\
Supérieur\\
et de la Recherche Scientifique\\
\textbf{-- -- -- $\star\star\star$ -- -- --}\\
Université de xxxxx\\
\textbf{-- -- -- $\star\star\star$ -- -- --}\\
Faculté des Sciences \'Economiques\\
et de Gestion de xxxxx\\
\vspace{-0.5cm}\includegraphics[width=3cm]{example-image} \\
\end{tabular}
& &
\begin{tabular}{0l|p{8cm}}
Matière & Mathématiques II (Analyse)\\ \hline
Niveau et Filière & Première année (Licence en Sciences \'Economiques)\\ \hline
Enseignant & Monsieur xxxxxxxxxxxx\\ \hline
Session & Principale (Juin 2023) \\ \hline
Durée & 2 heures\\ \hline
Nombre de Pages & 2 \\
\end{tabular}\\
\cline{1-1} \cline{3-3}
\end{tabular}
%-------------- FIN DE L'ENTETE----------------------
\vspace{0.2cm}
\noindent{\underline{\bf Directives pédagogiques :}}
\begin{itemize}
\item [\circled{R}] Aucune documentation n'est permise.
\item [\circled{R}] La qualité de la rédaction, la clarté et la précision des interprétations entreront pour une part importante dans l'appréciation finale.
\end{itemize}}
%\vspace{-0.5cm}
%%%%%%%%%%%%%%%% début exercice%%%%%%%%%%%%%%%%%%%
\exo{: ($4$ points)}
\finexo
%%%%%%%%%%%%%%%% fin exercice%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%% début exercice%%%%%%%%%%%%%%%%%%%
\exo{: ($5$ points)}
\finexo
%%%%%%%%%%%%%%%% fin exercice%%%%%%%%%%%%%%%%%%%
%-encouragement--
\begin{flushright}
{\large\ding{95}} {\large\ding{95}}
\emph{\textbf{\underline{Bon travail}}} {\large\ding{95}}
{\large\ding{95}}
\end{flushright}
%---
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
However, the header takes up a great deal of space. I would like to minimize the extra spaces. Additionally, any suggestions for improvement are appreciated. I want the end of the second table to be at the same level as the text boundary.



\parindent. Change this length to 0pt or use\noindentjust before the tabular. – Fran May 17 '23 at 17:06mathtoolsloadsamsmath, andamssymbloadsamsfonts, so some streamlining is possible. – barbara beeton May 17 '23 at 17:24\begin{tabular}by\noindent\begin{tabular}. This solve your problem? (BTW, pay attention to your own comment in the second line of code). – Fran May 17 '23 at 20:31\vspace{-0.5cm}before the image and set both\cellspacetoplimitand\cellspacebottomlimitas low as possible (,i.e., 9pt, less will have ugly results). – Fran May 18 '23 at 09:30