2

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} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

enter image description here

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.

Student
  • 1,134
  • 2
  • 9
  • 27
  • If you mean an the extra space in left margin, note that a tabular is positioned just like a big single character. It start a paragraph no matter if there are really a paragraph after it, so by default is indented as set in \parindent. Change this length to 0pt or use \noindent just before the tabular. – Fran May 17 '23 at 17:06
  • Off topic: mathtools loads amsmath, and amssymb loads amsfonts, so some streamlining is possible. – barbara beeton May 17 '23 at 17:24
  • @Fran I'm sorry since I don't understand your comment – Student May 17 '23 at 19:34
  • @Student Just change the first \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
  • Thanks a lot @Fran but there is also some extra spaces in the two tables – Student May 18 '23 at 02:38
  • @Student Remove the \vspace{-0.5cm} before the image and set both \cellspacetoplimit and \cellspacebottomlimit as low as possible (,i.e., 9pt, less will have ugly results). – Fran May 18 '23 at 09:30
  • @Fran I'm sorry since the file does not compiles to me – Student May 19 '23 at 03:53

2 Answers2

3

Here are two different fixes:

mwe

The first (the recommended) is a single table using tabulary, multirow and array, and the other is your nested tabulars with the fixes of the comments, plus tabularx to fit the text boundary as you asked in your last edit

(note: in the edits, please add what you need to clarify the question but do not remove/change the original post, since then the comments or answers could have no sense for another users).

(note: I removed parts of the preamble that are irrelevant for the issue in order to simplify the example, but that maybe your will need in your working document. So, to check that solutions in your working document do not change the preamble except to add mentioned packages (i.e., just add the second line of the code below.)

\documentclass[12pt,a4paper]{article}
\usepackage{tabularx,tabulary,multirow,array} 
\usepackage{graphicx,amsthm,mathtools}
\usepackage{tikz}

\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{geometry}\geometry{left=1.5cm,right=1.5cm,top=1.0cm,bottom=1.5cm}

\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}}

\usepackage[column=0]{cellspace} \setlength{\cellspacetoplimit}{9pt} \setlength{\cellspacebottomlimit}{9pt}

\begin{document}

% Method 1: A single table

\begin{table}[t] \scriptsize\bfseries \renewcommand\arraystretch{3.3}% \extrarowheight-2pt \begin{tabulary}{\linewidth}{|C|L|l|l|} \cline{3-4}\cline{1-1} \multirow{6}{=}{\centering Ministère de l'Enseignement \par Supérieur \par et de la Recherche Scientifique\par \textbf{-- -- -- $\star\star\star$ -- -- --}\par Université de xxxxx\par \textbf{-- -- -- $\star\star\star$ -- -- --}\par Faculté des Sciences 'Economiques \par et de Gestion de xxxxx\par \medskip\includegraphics[width=3cm]{example-image} } & & Matière & Mathématiques II (Analyse)\\cline{3-4} & & Niveau et Filière & Première année (Licence en Sciences 'Economiques)\\cline{3-4} & & Enseignant & Monsieur xxxxxxxxxxxx\\cline{3-4} & & Session & Principale (Juin 2023) \\cline{3-4} & & Durée & 2 heures\\cline{3-4} & & Nombre de Pages & 2 \\cline{1-1}\cline{3-4} \end{tabulary} \end{table}

% Method 2: Fix your table with tabularx

{\scriptsize\bfseries \noindent\begin{tabularx}{\linewidth}{|@{}c@{}|X|@{}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\ \includegraphics[width=3cm]{example-image} \ \end{tabular} & & \begin{tabular}{0l|p{8.3cm}} 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{tabularx}

\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}} \exo{: ($4$ points)} \finexo \exo{: ($5$ points)} \finexo \begin{flushright} {\large\ding{95}} {\large\ding{95}} \emph{\textbf{\underline{Bon travail}}} {\large\ding{95}} {\large\ding{95}} \end{flushright} %--- \end{document}

Additionally, any suggestions for improvement are appreciated.

OK:

MWE

\documentclass[12pt,a4paper]{article}
\usepackage{tabularx,tabulary,multirow,array,booktabs,xcolor} 
\usepackage{pgfornament} 
\usepackage{graphicx,amsthm,mathtools}

\usepackage[french]{babel} \usepackage{pifont} %bouni \usepackage{fancybox} %pour faire l'encadrement

\usepackage{geometry}\geometry{left=1.5cm,right=1.5cm,top=1.0cm,bottom=1.5cm}

\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}}

\begin{document}

\begin{table}[t] \renewcommand\arraystretch{2.3}%\extrarowheight-2pt \footnotesize \begin{tabularx}{\linewidth}{p{5.2cm}X>{\color{green!40!black}\sffamily}l>{\color{blue!40!black}\sffamily}l} \toprule \multirow{6}{=}{\centering%\bfseries Ministère de l'Enseignement Supérieur et de la Recherche Scientifique

\pgfornament[width=2cm]{83}

Université de xxxxx\par

\pgfornament[width=2cm]{83}

Faculté des Sciences Économiques et de Gestion de xxxxx

\medskip\includegraphics[width=3cm]{example-image}

} & & Matière: & Mathématiques II (Analyse)\ & & Niveau et Filière: & Première année (Licence en Sciences 'Economiques)\ & & Enseignant: & Monsieur Dr. Moreau \ & & Session: & Principale (\today) \ & & Durée: & 2 heures\ & & Nombre de Pages: & 2 \\bottomrule \end{tabularx} \end{table}

\subsubsection*{Directives pédagogiques:}

\begin{itemize}\itemsep1ex \item [\textregistered] Aucune documentation n'est permise. \item [\textregistered] 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}

\exo{: ($4$ points)} \finexo \exo{: ($5$ points)} \finexo \begin{flushright} {\large\ding{95}} {\large\ding{95}} \emph{\textbf{\underline{Bon travail}}} {\large\ding{95}} {\large\ding{95}} \end{flushright} %--- \end{document}

Fran
  • 80,769
  • Thanks a lot. please just add a space betwen the end of the table and Directives pédagogiques. I replaced ```\vspace{0.2cm}

    \noindent{\underline{\bf Directives pédagogiques :}}by\vspace{0.7cm}

    \noindent{\underline{\bf Directives pédagogiques :}}``` but the space does not change

    – Student May 20 '23 at 06:38
  • @Student \vspace ignored in places as the top of the page or after a top float where usually it have no sense. You can force the spacing with \vspace, but in general, when you insert manually spaces, your are going in the wrong direction, for instance, formating manually headers (bold and underlined text) instead of use some like `\subsubsection` that will take care of the spacing automatically. – Fran May 20 '23 at 07:52
  • Thanks a lot. But I used {\scriptsize\bfseries \subsubsection*{\underline{Directives pédagogiques:}} \begin{itemize}\itemsep1ex \item [\textregistered] Aucune documentation n'est permise. \item [\textregistered] 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}} the title of subsection is always in the same size. I like the size will be less – Student May 20 '23 at 08:27
  • @Student (1) If you do not want the default style of commands as \section{foo} (font type, size, color, spacing above and below, whatever ...) change that style in the preamble, do not try to re-format the argument "foo" manually in the text. (2) The style it is a matter of taste, but underlines always make the text less legible, heavy and cluttered. – Fran May 20 '23 at 09:11
1

Well, because you have already made some advanced formatting, I am wondering why can't we just use \resizebox{<*width-value*>}{<*height-value*>}{<*content*>} to embrace the two tabular forms and if row height seems problematic this answer makes it clear. I can understand this should be in comment section of your question but I have not enough reputation to do so.

  • please provide me the code in order to compile it. Thanks – Student May 20 '23 at 08:15
  • 1
    Resize a table to fit the margins is always a bad idea in table design because you will not have any control of the final font size and thickness of the rules, so inconsistent with the rest of the document, beside that even if you can shrink or stretch a normal font to be exactly as big as \huge, or as little as \tiny, the result is not the same: the font will be not the same (see here). – Fran May 20 '23 at 08:18
  • @Student as @Fran has already referred to some discrepancies to this method, I am not editing my answer. But to see the outcome you can add \resizebox{0.62\textwidth}{!}{ at the beginning of line 86 and a closing } to at the end of line 93. – Debanjan Dutta May 20 '23 at 10:03