2

I created this table:

\begin{table}[!h]
\caption{\label{tab:choix-de-carriere-different}Choix de carrière: ingénieur logiciel}
\centering
\begin{tabularx}{\linewidth}{|p{10 em}|X|}
\hline
\textbf{Information} & \textbf{Recherche}\\
\hline
Description de la carriére &
Les ingénieurs logiciels se concentrent sur l'application des principes d'ingénierie aux programmes. Chaque ingénieur logiciel écrit et valide le code des programmes d'une entreprise. Tout comme les avocats, les ingénieurs en logiciel se spécialisent dans différents domaines. Il y a le développement Web, le traitement de texte, le développement de jeux.\\
\hline
Habiletés et compétences nécessaires pour cet emploi &
\begin{itemize} \item savoir le codage \item bien à créer la documentation \item savoir des langages de programmation \item savoir des compilateurs \item savoir des licences de logiciels \item bien au débogage \end{itemize}\\
\hline
\end{tabularx}
\end{table}

There is a lot of white space when it comes to lists. There is white space before the list, after the list, to the left of the list, and between list items. I partially solved this by defining a new environment (\tabitem) and using it instead of (itemize).

\usepackage{enumitem}

\newenvironment{tabitem}{ \setlist{leftmargin = *, topsep=0pt,parsep=0pt,partopsep=0pt} \vspace{-2.5 mm} \begin{itemize} \tightlist} {\end{itemize}}

But there is still white space below the list. How can I remove it?

Amarakon
  • 165

1 Answers1

3

You're on the right track by loading the enumitem package and trying to create a bespoke itemize-like environment. I'd just go even further, though, and create a new list environment called tabitemize. The result of applying the tabitemize environmennt is shown in the first table in the following screenshot. The tabitemize code is used frequently on this site, most recently (I think) in this answer.

I'd like to encourage you to go even further in improving the table's layout, by (a) omitting all vertical lines (trust me, they won't be misssed), (b) using the macros of the booktabs package to generate well-spaced horizontal lines, not bold-facing the text in the header line, and using ragged-right instead of full justification for the contents of the first column. The result of these adjustments is shown in the second table in the following screenshot.

enter image description here

\documentclass{article} % or some other suitable document class
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{tabularx}

% Optional: Fine-tune appearance of figure and table captions: \usepackage[justification=raggedright, singlelinecheck=off, skip=0.333\baselineskip, labelfont=bf, labelsep=colon]{caption}

% Define a bespoke environment for compact itemize-like lists: \usepackage{enumitem} \newlist{tabitemize}{itemize}{1} \setlist[tabitemize]{label=\textbullet, nosep, leftmargin=*, before={\begin{minipage}[t]{\hsize}}, after ={\end{minipage}}}

% Packages needed only for second table: \usepackage{ragged2e} % for \RaggedRight macro \usepackage{booktabs} % for \toprule, \midrule, \bottomrule, % and \addlinespace macros

\begin{document}

\begin{table}[!h] \caption{Choix de carrière: ingénieur logiciel} \label{tab:choix-de-carriere-different}

%%\centering % does nothing useful \begin{tabularx}{\linewidth}{|p{10em}|X|} \hline \textbf{Information} & \textbf{Recherche}\ \hline Description de la carrière & Les ingénieurs logiciels se concentrent sur l'application des principes d'ingénierie aux programmes. Chaque ingénieur logiciel écrit et valide le code des programmes d'une entreprise. Tout comme les avocats, les ingénieurs en logiciel se spécialisent dans différents domaines. Il y a le développement Web, le traitement de texte, le développement de jeux.\ \hline Habiletés et compétences nécessaires pour cet emploi & \begin{tabitemize} \item savoir le codage \item bien à créer la documentation \item savoir des langages de programmation \item savoir des compilateurs \item savoir des licences de logiciels \item bien au débogage \end{tabitemize}\ \hline \end{tabularx}

\bigskip %% 2nd version of table: no vertical lines, well-spaced horizontal lines, %% ragged-right typesetting in first column, no bold-facing in header row \caption{Choix de carrière: ingénieur logiciel}

\begin{tabularx}{\linewidth}{@{} >{\RaggedRight}p{10em} X @{}} \toprule Information & Recherche \ \midrule Description de la carrière & Les ingénieurs logiciels se concentrent sur l'application des principes d'ingénierie aux programmes. Chaque ingénieur logiciel écrit et valide le code des programmes d'une entreprise. Tout comme les avocats, les ingénieurs en logiciel se spécialisent dans différents domaines. Il y a le développement Web, le traitement de texte, le développement de jeux.\ \addlinespace Habiletés et compétences nécessaires pour cet emploi & \begin{tabitemize} \item savoir le codage \item bien à créer la documentation \item savoir des langages de programmation \item savoir des compilateurs \item savoir des licences de logiciels \item bien au débogage
\end{tabitemize}\ \bottomrule \end{tabularx} \end{table}

\end{document}

Mico
  • 506,678
  • 1
    What about not using a tabular(x) at all? – egreg May 28 '22 at 08:03
  • @egreg - I guess I was assuming that it's important for the OP to employ a tabular[x] environment. Let's see if the OP weighs with additional information about his/her typographical requirements and stylistic preferences. – Mico May 28 '22 at 08:15
  • 1
    Wow, this is a great solution. Both of them work perfectly. But I have to ask, why are tables with vertical lines not liked generally in typography and by LaTeX users? To me, They make it easy to differentiate between all the cells. And making the top row bold also makes it stand out. Finally, I do not need to use tabularx. I am fine with any other table package. The reason I used it in my example is that just tabular caused the table to stretch all the way to the right of the page instead of going to a new line. – Amarakon May 28 '22 at 08:44
  • @Amarakon - Enclosing all table cells in a grid of vertical and horizontal lines does make it easy to differentiate among cells. But ask yourself: it is either necessary or advisable to provide such a rigid grid? I would argue, "no". Rigid grids tend to create the impression of a prison cell window. Those are anything but "inviting" or "welcoming" to the eye. By avoiding the "grid look", you're issuing a kind invitiation to your readers to "rest their eyes" for a while on the table -- and, while doing so, actually giving themselves a chance to take in the information contained in the table... – Mico May 28 '22 at 09:57
  • @Amarakon - Regarding your point, "And making the top row bold also makes it stand out" -- bolding certainly does make things stand out. But it's not the only technique to achieve emphasis, nor is it the best. The second table, which employs the visual device of placing 2 of the 3 sole horizontal lines close to the header material, succeeds rather well in making sure that the readers understand where the header cells are, while avoiding the trap of making readers focus excessively on just the header cells and distracing them from taking in all of the information in the table... – Mico May 28 '22 at 10:04
  • 1
    Thanks for explaining. The second table (booktabs) is growing on me. – Amarakon May 28 '22 at 10:33