1

This is my first question here. I read many topics, but none have solved my problem.

I need to split a table (using longtable or other) with the tabularx settings. I tried ltablex, but this changed all the other tables in the text. I also tried LTXtable, but I guess I did not know how to use it properly.

Below is the code and appearance using tabularx, as I want it to stay using longtable.

\documentclass{article}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{array}
\usepackage{float}
\begin{document}
\begin{table}[H]
    \centering
    \small
    \caption{Planejamento experimental.}
    \label{tab:MatrizPlanExp}
    \newcolumntype{C}{>{\centering\arraybackslash\hsize=1\hsize}X}
    \renewcommand{\arraystretch}{1.15} % Espaçamento
    \begin{tabularx}{\textwidth}{CCC}
        \toprule
        \textbf{Experimento nº} & \textbf{Temperatura (°C)} & \textbf{WHSV (h$^{-1}$)} \\
        \midrule
        1     & 240   & 40 \\
        2     & 240   & 45 \\
        3     & 240   & 50 \\
        4     & 240   & 55 \\
        5     & 240   & 60 \\
        6     & 260   & 40 \\
        7     & 260   & 45 \\
        8     & 260   & 50 \\
        9     & 260   & 55 \\
        10    & 260   & 60 \\
        11    & 280   & 40 \\
        12    & 280   & 45 \\
        13    & 280   & 50 \\
        14    & 280   & 50 \\
        15    & 280   & 50 \\
        16    & 280   & 55 \\
        17    & 280   & 60 \\
        18    & 300   & 5 \\
        19    & 300   & 10 \\
        20    & 300   & 20 \\
        21    & 320   & 2,5 \\
        22    & 320   & 5 \\
        23    & 320   & 10 \\
        24    & 320   & 20 \\
        25    & 340   & 2,5 \\
        26    & 340   & 5 \\
        27    & 340   & 10 \\
        28    & 340   & 20 \\
        \bottomrule
    \end{tabularx}
\end{table}
\end{document}

enter image description here

Here is the best I got using longtable (I have increased the lines to go to the other page).

\begin{document}
\begin{longtable}{@{}P{4cm}P{4cm}P{4cm}@{}}
    \caption{Planejamento experimental.}\\
    \toprule
    \textbf{Experimento nº} & \textbf{Temperatura (°C)} & \textbf{WHSV (h$^{-1}$)} \\
    \midrule
    1     & 240   & 40 \\
    2     & 240   & 45 \\
    3     & 240   & 50 \\
    4     & 240   & 55 \\
    5     & 240   & 60 \\
    6     & 260   & 40 \\
    7     & 260   & 45 \\
    8     & 260   & 50 \\
    9     & 260   & 55 \\
    10    & 260   & 60 \\
    11    & 280   & 40 \\
    12    & 280   & 45 \\
    13    & 280   & 50 \\
    14    & 280   & 50 \\
    15    & 280   & 50 \\
    16    & 280   & 55 \\
    17    & 280   & 60 \\
    18    & 300   & 5 \\
    19    & 300   & 10 \\
    20    & 300   & 20 \\
    21    & 320   & 2,5 \\
    22    & 320   & 5 \\
    23    & 320   & 10 \\
    24    & 320   & 20 \\
    25    & 340   & 2,5 \\
    26    & 340   & 5 \\
    27    & 340   & 10 \\
    28    & 340   & 20 \\
    19    & 300   & 10 \\
    20    & 300   & 20 \\
    21    & 320   & 2,5 \\
    22    & 320   & 5 \\
    23    & 320   & 10 \\
    24    & 320   & 20 \\
    25    & 340   & 2,5 \\
    26    & 340   & 5 \\
    27    & 340   & 10 \\
    28    & 340   & 20 \\
    20    & 300   & 20 \\
    21    & 320   & 2,5 \\
    22    & 320   & 5 \\
    23    & 320   & 10 \\
    24    & 320   & 20 \\
    25    & 340   & 2,5 \\
    26    & 340   & 5 \\
    27    & 340   & 10 \\
    \bottomrule
    \label{tab:MatrizPlanExp}\\
\end{longtable}
\end{document}

enter image description here

I would like to:

1) Use \small font with longtable without decreasing the font of the caption.

2) Have a row closing and starting the split table.

3) Write on the dividing page that the table continues on the next page, or something like that.

Please, help me.

  • 2
    We'lcome to TeX SX! What do you mean with ‘ltablex changed all other tables’? – Bernard Mar 18 '18 at 23:40
  • You did remove the table wrapper, right? You can't have a float split across pages, so you need to get rid of that. – cfr Mar 19 '18 at 2:40
  • I would never use tabularx for such a table, tabularx is designed to control line breaking within the table cells and you have no linebreaking in these kinds of data tables, so the only effect of forcing the table to be \textwidth wide is that the columns are further apart so the table is harder to read. – David Carlisle Mar 19 '18 at 7:56
  • Bernard, with "ltablex changed all other tables" I meant that this command changed the formatting of all the other tables in my dissertation (another 20), which I configured individually. – Mellyssa Mar 21 '18 at 23:03
  • Crf, yes, I removed "table". Still, it was not what I wanted. Thanks. – Mellyssa Mar 21 '18 at 23:04
0

Are you trying to do something like this?

\documentclass[12pt]{article}
\usepackage{longtable}
\begin{document}
    \begin{small}
        \begin{longtable}{ p{4cm} p{4cm} p{4cm} }
            \caption{Planejamento experimental.} \\
            \hline
            \multicolumn{1}{c}{\textbf{Experimento nº}} & \multicolumn{1}{c}{\textbf{Temperatura (°C)}} & \multicolumn{1}{c}{\textbf{WHSV (h$^{-1}$)}} \\
            \hline
            \endfirsthead
            \multicolumn{3}{c}
            {\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
            \hline
            \multicolumn{1}{c}{\textbf{Experimento nº}} & \multicolumn{1}{c}{\textbf{Temperatura (°C)}} & \multicolumn{1}{c}{\textbf{WHSV (h$^{-1}$)}} \\
            \hline
            \endhead
            \hline \multicolumn{3}{r}{\textit{Continued on next page}} \\
            \endfoot
            \hline
            \endlastfoot
            \multicolumn{1}{c}{1}     & \multicolumn{1}{c}{240}   & \multicolumn{1}{c}{40} \\
            \multicolumn{1}{c}{2}     & \multicolumn{1}{c}{240}   & \multicolumn{1}{c}{45} \\
            \multicolumn{1}{c}{3}     & \multicolumn{1}{c}{240}   & \multicolumn{1}{c}{50} \\
            \multicolumn{1}{c}{4}     & \multicolumn{1}{c}{240}   & \multicolumn{1}{c}{55} \\
            \multicolumn{1}{c}{5}     & \multicolumn{1}{c}{240}   & \multicolumn{1}{c}{60} \\
            \multicolumn{1}{c}{6}     & \multicolumn{1}{c}{260}   & \multicolumn{1}{c}{40} \\
            \multicolumn{1}{c}{7}     & \multicolumn{1}{c}{260}   & \multicolumn{1}{c}{45} \\
            \multicolumn{1}{c}{8}     & \multicolumn{1}{c}{260}   & \multicolumn{1}{c}{50} \\
            \multicolumn{1}{c}{9}     & \multicolumn{1}{c}{260}   & \multicolumn{1}{c}{55} \\
            \multicolumn{1}{c}{10}    & \multicolumn{1}{c}{260}   & \multicolumn{1}{c}{60} \\
            \multicolumn{1}{c}{11}    & \multicolumn{1}{c}{280}   & \multicolumn{1}{c}{40} \\
            \multicolumn{1}{c}{12}    & \multicolumn{1}{c}{280}   & \multicolumn{1}{c}{45} \\
            \multicolumn{1}{c}{13}    & \multicolumn{1}{c}{280}   & \multicolumn{1}{c}{50} \\
            \multicolumn{1}{c}{14}    & \multicolumn{1}{c}{280}   & \multicolumn{1}{c}{50} \\
            \multicolumn{1}{c}{15}    & \multicolumn{1}{c}{280}   & \multicolumn{1}{c}{50} \\
            \multicolumn{1}{c}{16}    & \multicolumn{1}{c}{280}   & \multicolumn{1}{c}{55} \\
            \multicolumn{1}{c}{17}    & \multicolumn{1}{c}{280}   & \multicolumn{1}{c}{60} \\
            \multicolumn{1}{c}{18}    & \multicolumn{1}{c}{300}   & \multicolumn{1}{c}{5 }\\
            \multicolumn{1}{c}{19}    & \multicolumn{1}{c}{300}   & \multicolumn{1}{c}{10} \\
            \multicolumn{1}{c}{20}    & \multicolumn{1}{c}{300}   & \multicolumn{1}{c}{20} \\
            \multicolumn{1}{c}{21}    & \multicolumn{1}{c}{320}   & \multicolumn{1}{c}{2,5} \\
            \multicolumn{1}{c}{22}    & \multicolumn{1}{c}{320}   & \multicolumn{1}{c}{5} \\
            \multicolumn{1}{c}{23}    & \multicolumn{1}{c}{320}   & \multicolumn{1}{c}{10} \\
            \multicolumn{1}{c}{24}    & \multicolumn{1}{c}{320}   & \multicolumn{1}{c}{20} \\
            \multicolumn{1}{c}{25}    & \multicolumn{1}{c}{340}   & \multicolumn{1}{c}{2,5} \\
            \multicolumn{1}{c}{26}    & \multicolumn{1}{c}{340}   & \multicolumn{1}{c}{5} \\
            \multicolumn{1}{c}{27}    & \multicolumn{1}{c}{340}   & \multicolumn{1}{c}{10} \\
            \multicolumn{1}{c}{28}    & \multicolumn{1}{c}{340}   & \multicolumn{1}{c}{20} \\
            \multicolumn{1}{c}{19}    & \multicolumn{1}{c}{300}   & \multicolumn{1}{c}{10} \\
            \multicolumn{1}{c}{20}    & \multicolumn{1}{c}{300}   & \multicolumn{1}{c}{20} \\
            \multicolumn{1}{c}{21}    & \multicolumn{1}{c}{320}   & \multicolumn{1}{c}{2,5} \\
            \multicolumn{1}{c}{22}    & \multicolumn{1}{c}{320}   & \multicolumn{1}{c}{5} \\
            \multicolumn{1}{c}{23}    & \multicolumn{1}{c}{320}   & \multicolumn{1}{c}{10} \\
            \multicolumn{1}{c}{24}    & \multicolumn{1}{c}{320}   & \multicolumn{1}{c}{20} \\
            \multicolumn{1}{c}{25}    & \multicolumn{1}{c}{340}   & \multicolumn{1}{c}{2,5} \\
            \multicolumn{1}{c}{26}    & \multicolumn{1}{c}{340}   & \multicolumn{1}{c}{5} \\
            \multicolumn{1}{c}{27}    & \multicolumn{1}{c}{340}   & \multicolumn{1}{c}{10} \\
            \multicolumn{1}{c}{28}    & \multicolumn{1}{c}{340}   & \multicolumn{1}{c}{20} \\
            \multicolumn{1}{c}{20}    & \multicolumn{1}{c}{300}   & \multicolumn{1}{c}{20} \\
            \multicolumn{1}{c}{21}    & \multicolumn{1}{c}{320}   & \multicolumn{1}{c}{2,5} \\
            \multicolumn{1}{c}{22}    & \multicolumn{1}{c}{320}   & \multicolumn{1}{c}{5} \\
            \multicolumn{1}{c}{23}    & \multicolumn{1}{c}{320}   & \multicolumn{1}{c}{10} \\
            \multicolumn{1}{c}{24}    & \multicolumn{1}{c}{320}   & \multicolumn{1}{c}{20} \\
            \multicolumn{1}{c}{25}    & \multicolumn{1}{c}{340}   & \multicolumn{1}{c}{2,5} \\
            \multicolumn{1}{c}{26}    & \multicolumn{1}{c}{340}   & \multicolumn{1}{c}{5} \\
            \multicolumn{1}{c}{27}    & \multicolumn{1}{c}{340}   & \multicolumn{1}{c}{10} \\
        \end{longtable}
    \end{small}
\end{document}
  • I tried various means to eliminate or minimize the redundant multicolumn commands to center the fields under each column, but unfortunately, nothing seemed to work with the longtable other than the multicolumn{1} for each cell. Trying to do a multicolumn{3} doesn't work. I'm new at LaTeX myself and thought I'd tackle your question for my own learning. – Terin D'Amico Mar 19 '18 at 3:41
  • Yeah, that's how I wanted it to go. Thank you. – Mellyssa Mar 21 '18 at 22:58

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.