0

I am new to LaTeX. I am trying to change a tablarx into a longtable and to keep the caption below the table. I tried many answers such as this one but none seem to work to me.

%\linebreak
\documentclass[a4paper,12pt]{report}
\usepackage{wrapfig}
\usepackage{units}
\usepackage[utf8x,utf8]{inputenc}
\usepackage{ltxtable}
\usepackage{filecontents}
\usepackage{pbox}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{tabularx}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{blindtext}
\usepackage{enumitem}
%\bibliographystyle{apalike}


\begin{document}

\begin{table}[H]
    \centering
\begin{tabularx}{\textwidth}{|X|X|X|X|X|X|}
\hline          
    Chevauche- ment &   Méthode de détection & Paramètre & Nombre de communautés & Nombre moyen de communautés par snapshot & Taille moyenne de communautés \\

    \hline          
    \multirow{4}{*}{$0\%$} & \multirow{3}{*}{CPM} & 3 & 14066 & 275.80 & 4.60\\
    \cline{3-6}
    & & 5 & 99 & 3.67 & 5.77 \\
    \cline{3-6}
    & & 7 & 0 & 0 & 0 \\
    \cline{2-6}
    & SLPA & & 20393 & 755.30 & 12.25 \\
    \hline 

    \multirow{4}{*}{$20\%$} & \multirow{3}{*}{CPM} & 3 & 15176 & 459.88 & 4.62\\
    \cline{3-6}
    & & 5 & 133 & 4.03 & 5.82 \\
    \cline{3-6}
    & & 7 & 0 & 0 & 0 \\
    \cline{2-6}
    & SLPA & & 24152& 731.88 & 12.51 \\
    \hline 

    \multirow{4}{*}{$50\%$} & \multirow{3}{*}{CPM}  & 3 & 24698 & 466 & 4.59\\
    \cline{3-6}
    & & 5 & 200 & 3.77 & 5.85 \\
    \cline{3-6}
    & & 7 & 2 & 0.04 & 7.5 \\
    \cline{2-6}
    & SLPA & & 39661 & 748.32 & 12.44 \\
    \hline 
\end{tabularx}
    \caption{Caractéristiques des communautés de Facebook en variant le taux de chevauchement de snapshots et la méthode de détection des communautés}
    \label{facebook-Detect-test-label}

\end{table}

\end{document}

Any help on how I can convert this table into longtable?

Edit my Manuel Kuehner

I changed the code to be more minimal. Most of the packages had no relation to the question.

\documentclass{report}

% Ltxtable pro­vides the func­tion­al­ity of longtable and tab­u­larx to­gether in­side a longtable en­vi­ron­ment.
\usepackage{ltxtable}

\usepackage{booktabs}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{tabularx}

\begin{document}

\begin{table}
    \centering
\begin{tabularx}{\textwidth}{|X|X|X|X|X|X|}
\hline          
    Chevauche- ment &   Méthode de détection & Paramètre & Nombre de communautés & Nombre moyen de communautés par snapshot & Taille moyenne de communautés \\

    \hline          
    \multirow{4}{*}{$0\%$} & \multirow{3}{*}{CPM} & 3 & 14066 & 275.80 & 4.60\\
    \cline{3-6}
    & & 5 & 99 & 3.67 & 5.77 \\
    \cline{3-6}
    & & 7 & 0 & 0 & 0 \\
    \cline{2-6}
    & SLPA & & 20393 & 755.30 & 12.25 \\
    \hline 

    \multirow{4}{*}{$20\%$} & \multirow{3}{*}{CPM} & 3 & 15176 & 459.88 & 4.62\\
    \cline{3-6}
    & & 5 & 133 & 4.03 & 5.82 \\
    \cline{3-6}
    & & 7 & 0 & 0 & 0 \\
    \cline{2-6}
    & SLPA & & 24152& 731.88 & 12.51 \\
    \hline 

    \multirow{4}{*}{$50\%$} & \multirow{3}{*}{CPM}  & 3 & 24698 & 466 & 4.59\\
    \cline{3-6}
    & & 5 & 200 & 3.77 & 5.85 \\
    \cline{3-6}
    & & 7 & 2 & 0.04 & 7.5 \\
    \cline{2-6}
    & SLPA & & 39661 & 748.32 & 12.44 \\
    \hline 
\end{tabularx}
    \caption{Caractéristiques des communautés de Facebook en variant le taux de chevauchement de snapshots et la méthode de détection des communautés}
\end{table}

\end{document}
2

the direct translation would be as below, although I would never use p or X columns for tables of data.

\documentclass[a4paper,12pt]{report}
\usepackage{wrapfig}
\usepackage{units}
\usepackage[utf8x,utf8]{inputenc}
\usepackage{ltxtable}
\usepackage{filecontents}
\usepackage{pbox}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{tabularx}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{blindtext}
\usepackage{enumitem}
%\bibliographystyle{apalike}


\begin{document}

\newcolumntype{Y}{p{\dimexpr(\textwidth-7\arrayrulewidth-12\tabcolsep)/6\relax}}
\begin{longtable}{|Y|Y|Y|Y|Y|Y|}
    \caption{Caractéristiques des communautés de Facebook en variant le taux de chevauchement de snapshots et la méthode de détection des communautés}
    \label{facebook-Detect-test-label}\\
\hline          
    Chevauche- ment &   Méthode de détection & Paramètre & Nombre de communautés & Nombre moyen de communautés par snapshot & Taille moyenne de communautés \\

    \hline          
    \multirow{4}{*}{$0\%$} & \multirow{3}{*}{CPM} & 3 & 14066 & 275.80 & 4.60\\
    \cline{3-6}
    & & 5 & 99 & 3.67 & 5.77 \\
    \cline{3-6}
    & & 7 & 0 & 0 & 0 \\
    \cline{2-6}
    & SLPA & & 20393 & 755.30 & 12.25 \\
    \hline 

    \multirow{4}{*}{$20\%$} & \multirow{3}{*}{CPM} & 3 & 15176 & 459.88 & 4.62\\
    \cline{3-6}
    & & 5 & 133 & 4.03 & 5.82 \\
    \cline{3-6}
    & & 7 & 0 & 0 & 0 \\
    \cline{2-6}
    & SLPA & & 24152& 731.88 & 12.51 \\
    \hline 

    \multirow{4}{*}{$50\%$} & \multirow{3}{*}{CPM}  & 3 & 24698 & 466 & 4.59\\
    \cline{3-6}
    & & 5 & 200 & 3.77 & 5.85 \\
    \cline{3-6}
    & & 7 & 2 & 0.04 & 7.5 \\
    \cline{2-6}
    & SLPA & & 39661 & 748.32 & 12.44 \\
    \hline 



\end{longtable}

\end{document}
|improve this answer|||||
  • Thanks. It was specified in the question that the caption is needed to be below the table. – Joker 00 Jun 10 '17 at 14:52
  • 1
    @Joker00 well no matter, the \caption just goes wherever you put it so you can change that easily enough. – David Carlisle Jun 10 '17 at 14:56

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.