1

I created a table in LaTeX using longtable. I need to have lists inside cells. I used \tabitem for that matter but I get not well aligned items. Here is my code:

\newcommand{\tabitem}{~~\llap{\textbullet}~~}

\begin{longtable}[H]{| m{5cm} | m{5cm}| m{5cm} | }\hline 
%\begin{center}
%\begin{tabular}{ | m{5cm} | m{5cm}| m{5cm} | } 
%\hline
Méthode de validation & Avantages  & Inconvénients \\ 
\hline
Resubstitution Validation &  \tabitem Simple  & \smallskip \tabitem Surapprentissage \\ 
\hline
Hold-out Validation & \tabitem Apprentissage et tests indépendants & \tabitem Réduction des données utilisées pour l'apprentissage et les tests \newline \smallskip \tabitem Grande variance  \\ 
\hline
k-fold cross Validation & \tabitem Estimation précise des performances & \tabitem Petits échantillons d'estimation des performances \newline \smallskip \tabitem Données d'apprentissage chevauchées \newline \smallskip \tabitem Variance de la performance sous-estimée ou degré de liberté de comparaison surestimé
\\ 
\hline
Leave-One-Out Validation cross-validation & \smallskip \tabitem Estimation non biaisée de performance \newline \smallskip \tabitem Haute exploitation de données pour l’apprentissage & \smallskip \tabitem Variance très large
\\ 
\hline
Repeated k-fold cross-validation & \smallskip \tabitem Grand nombre d’estimation de performance & \smallskip \tabitem Chevauchement des données d'entraînement et d'essai entre chaque itération. \newline \smallskip \tabitem  Variance de la performance sous-estimée ou degré de liberté de comparaison surestimé
\\ 
\hline
%\end{tabular}
%\end{center}
\caption{Caractéristiques des méthodes de validation}
%\end{table}
\end{longtable}

Here is what I get:

enter image description here

As you can see, items are not all aligned in the same way (in the third column). How can I aligned all list items?

2

I prefer the following form of the your table:

enter image description here

The code for above table has slightly more sophisticated preamble, but table typing is almost the same as in your code shown in question:

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{array,booktabs}

% added packages and column definitions
\usepackage{ragged2e}           % for smart align of cells' content
    \usepackage{enumitem}       % for nice list
\newlist{tabitemize}{itemize}{1}% <-- defined new list
\setlist[tabitemize]{nosep,     % <-- new list setup
                     topsep     = 0pt       ,
                     partopsep  = 0pt       ,
                     leftmargin = *         ,
                     label      = $\bullet$ ,
                     before     = \vspace{-0.6\baselineskip},
                     after      = \vspace{-\baselineskip}
                     }
\newcolumntype{I}[1]{>{\RaggedRight\arraybackslash             % <-- for lists in columns
                    \tabitemize} p{#1}<{\endtabitemize}}
\newcommand\mch[1]{\multicolumn{1}{c}{\small\itshape{#1}}}  % <-- for columns headers  

\begin{document}
\begin{tabular}{@{} >{\RaggedRight}p{4cm} *{2}{I{4cm}} @{}}
  \toprule
\mch{Méthode de validation}
    &   \mch{Avantages}   &   \mch{Inconvénients} \\
  \midrule
Resubstitution Validation
    &   \item simple
        \item effortles
        &    \item Surapprentissage                 \\
    \addlinespace
Hold-out Validation 
    &   \item   Apprentissage et tests indépendants 
        &    \item   Réduction des données utilisées pour l'apprentissage et les tests
            \item   Grande variance                 \\
    \addlinespace
k-fold cross Validation 
    &   \item   Estimation précise des performances 
        &   \item   Petits échantillons d'estimation des performances 
            \item   Données d'apprentissage chevauchées
            \item   Variance de la performance sous-estimée ou degré de liberté de comparaison surestimé               \\
    \addlinespace
Leave-One-Out Validation cross-validation 
    &   \item   Estimation non biaisée de performance 
        \item   Haute exploitation de données pour l’apprentissage 
        &   \item   Variance de la performance sous-estimée ou degré de liberté de comparaison surestimé                       \\
    \addlinespace
Repeated k-fold cross-validation 
    &   \item   Grand nombre d’estimation de performance 
        &   \item   Chevauchement des données d'entraînement et d'essai entre chaque itération.
            \item   Variance de la performance sous-estimée ou degré de liberté de comparaison surestimé               \\
    \bottomrule
\end{tabular}
\end{document}

Above code with contained comments should be self-explanatory :). If the longtable is essential, than

\begin{tabular}{@{} >{\RaggedRight}p{4cm} *{2}{I} @{}}

replace with

\begin{longtable}{@{} >{\RaggedRight}p{4cm} *{2}{I} @{}}

and \end{tabular} with \end{longtable}.

4

Why don't you use the standard itemize environment in your table?

I tried a smaller example, to illustrate it. It does not have that much text as your, but I think, that won't hurt.

I also added package array and package booktabs. booktabs draws those nice lines. You should not need more than that few lines. Read the manual of that package.

Here is my example:

\documentclass[a4paper]{article}
\usepackage{array}
\usepackage{booktabs}

\newcolumntype{T}{%
  >{\scriptsize}c}

\begin{document}
\begin{tabular}{@{} *{3}{m{4cm}} @{}}
  \toprule

  \multicolumn{1}{@{}T}{Méthode de validation}
    & \multicolumn{1}{T}{Avantages} 
    & \multicolumn{1}{T@{}}{ Inconvénients} \\ 
  \midrule
  Resubstitution Validation 
    & \begin{itemize}
          \item simple
          \item effortles
          \end{itemize}
    & \begin{itemize}
          \item Surapprentissage
          \end{itemize}\\
  \bottomrule
\end{tabular}
\end{document}

This is the result

enter image description here

Of course, regardless the solution you are using: you should have at least two \items in every list, otherwise it won't be a list!

Maybe you will load the enumitem package. It is very mighty, to change the various dimensions of any list.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.