0

I'm trying to convert this table into longtable:

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{array,booktabs}
\usepackage{ragged2e} 
\usepackage{float}
% 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{#1}}}  % <-- for columns header

\begin{document}

\begin{table}[H]
\centering
\begin{tabular}{@{} >{\RaggedRight}p{4cm} *{2}{I{4.5cm}} @{}}
  \toprule
\mch{Méthode de validation}
    &   \mch{Avantages}   &   \mch{Inconvénients} \\
  \midrule
Resubstitution Validation
    &   \item simple
        \item effortles
        &    \item Surapprentissage                 \\
    \bottomrule
        \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                 \\
    \bottomrule
        \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é               \\
    \bottomrule
        \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é                       \\
    \bottomrule
        \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
        \addlinespace
\end{tabular}
    \caption{My caption below table} %%%% <-- caption
\label{tab:items}
\end{table}
\end{document}

I added longtable package and converted table into longtable but I'm getting many errors, about the caption and centering.

2

Here it is. In a long table, the caption has to be declared in the firsthead part, or, if you insist, in the lastfoot part. However, traditionally, table captions are written above the table, for the very simple reasons that 1) as a table consists of a series of data (numbers, text), the reader usually wants to know what it's about before reading, and have the possibility to skip it if not interested; 2) if the table breaks across pages (as is the case for long tables) the reader doesn't want to have to turn pages before he/she knows what it's about, then go back to the beginning of the table.

So I put it above the table, but, should you have specific reasons, that is easy to change. Note longtables are always centred by default, and require two (or more, sometimes) compilations. Also, longtables do not break in the middle of a row, and this implies, with multiline cells, that you may have blank spaces at the bottom of pages.

\documentclass[a4paper, french]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[showframe]{geometry}%
\usepackage{babel}
 \usepackage{array,booktabs, longtable}
\usepackage{ragged2e}
\usepackage{float}
% 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{#1}}} % <-- for columns header

\begin{document}

\vspace*{10cm}

\begin{longtable}{@{} >{\RaggedRight}p{4cm} *{2}{I{4.5cm}} @{}}
  \toprule
\mch{Méthode de validation}
    & \mch{Avantages} & \mch{Inconvénients} \endfirsthead
  \toprule
\mch{Méthode de validation}
    & \mch{Avantages} & \mch{Inconvénients} %
\endhead
\addlinespace
 \caption{Le caption bellow la table\enspace (To be continued)}
\label{tab:items}
\endfoot
\bottomrule
\addlinespace
 \caption{Le caption bellow la table\enspace (Fin)} %%%% <-- caption
\endlastfoot
\toprule
\mch{Méthode de validation}
 & \mch{Avantages} & \mch{Inconvénients} \\
 \midrule
Resubstitution Validation
    & \item simple
        \item effortles
        & \item Surapprentissage \\
    \midrule
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 \\
    \midrule
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é \\
    \midrule
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é \\
    \midrule
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é \end{longtable}

\end{document} 

enter image description here enter image description here

  • You put the code in the endfoot and endlastfoot sections, and adapt the text. Please see my updated answer for a possibility. – Bernard Jan 15 '17 at 1:29
  • It should be below. Thank you for your helpful answer. – Joker 00 Jan 15 '17 at 1:35

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.