# Longtable with specific columnwidth

I have been trying to resolve this for days and now I surrender. I need a table that can span multiple pages, so I started using longtable instead of tabularx. I tried to do a fixed width column (the first one) but I still get it too wide. when I try to shrink it to 3 or 4cm, it doesn't work.

\section{Main structural statistical parameters for the conformers calculated}
\begin{landscape}
\setlength\LTleft{-2cm}
\setlength\LTright{-4cm}
\begin{longtable}{r{4cm} |c|c|c|c|c|}
\caption[Chemical shift list of PG-T4 in \ce{H2O}, pH 3.5] {Main structural statistical parameters for the ensemble of the 20 lowest target function conformers calculated for PG-T4, PG-C6C15, PG-C8C13 in \ce{H2O} and 30 mM DPC, pH 3.5}\\
\toprule
&
\multicolumn{3}{c}{\textbf{\ce{H2O}}}   &
\multicolumn{3}{c}{\textbf{30 mM DPC}}   \\
\cmidrule(lr){2-4}
\cmidrule(lr){5-7}
&
\textbf{PG-T4} &
\textbf{PG-C6C15} &
\textbf{PG-C8C13} &
\textbf{PG-T4} &
\textbf{PG-C6C15} &
\textbf{PG-C8C13}
\\

\toprule
& &
\textbf{PG-T4}  &
\textbf{PG-C6C15}  &
\textbf{PG-C8C13}&
\textbf{PG-T4}  &
\textbf{PG-C6C15}  &
\textbf{PG-C8C13}
\\
\midrule
\bottomrule
\multicolumn{7}{r}{\footnotesize\itshape continue on the next page} % <-- added
\endfoot
\endlastfoot

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Upper Limit distance restraints (from NOEs)             &       &       &       &       &       &       \\
\tab Total  &   numbers &   numbers &   numbers &   numbers &   numbers &   numbers \\
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\bottomrule
\end{longtable}
\end{landscape}
\clearpage


If you can help me to find what's happening here, I would be very thankful.

I tried your solutions, @koleygr and this is the result:

• A first comment (that may solve your problem) is that I see 7 columns in the output but you use only 6 when defining the table... This is possibly that causes the problem – koleygr Jan 22 '18 at 12:12
• r{4cm} doesn't exist. probably you looking for >{\raggedleft\arraybacslash}p{4cm}. for numbers are advisable useS columns from siunitx package ... – Zarko Jan 22 '18 at 12:33

with ltablex, which is combination of longtable and tabularx, you can write long table in tabularx format.

an example (based on mwe in koleygr answer) anticipated that "numbers" will ones be real numbers, for which i suggest to use S column type from siunitx package, is:

\documentclass{article}
\usepackage{geometry}
\usepackage{pdflscape}
\usepackage{booktabs, makecell, ltablex, tabularx}
\keepXColumns
\usepackage{mhchem}
\usepackage{siunitx}

\begin{document}
\begin{landscape}
\setlength\LTcapwidth{\linewidth}
\begin{tabularx}{\linewidth}{>{\raggedright\arraybackslash}X *{6}{S[table-format=2.3]}}
\caption[Chemical shift list of PG-T4 in \ce{H2O}, pH 3.5]
{Main structural statistical parameters for the ensemble of the 20 lowest target function conformers calculated for PG-T4, PG-C6C15, PG-C8C13 in \ce{H2O} and 30 mM DPC, pH 3.5}
\label{tab:long-table}  \\
\toprule
&
\cmidrule(lr){2-4}  \cmidrule(lr){5-7}
\midrule
\caption{Main structural statistical parameters for the ensemble of the 20 lowest target function conformers calculated for PG-T4, PG-C6C15, PG-C8C13 in \ce{H2O} and 30 mM DPC, pH 3.5 (cont.)}\\
\toprule
&
\cmidrule(lr){2-4}  \cmidrule(lr){5-7}
\midrule
\midrule[\heavyrulewidth]
\multicolumn{7}{r}{\footnotesize\itshape continue on the next page}                 \\
\endfoot
\bottomrule
\endlastfoot
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Upper Limit distance restraints (from NOEs)
&           &           &           &           &           &               \\
Total   & 12.345    & 22.345    & 32.345    & 42.345    & 52.345    & 62.345        \\
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{tabularx}
\end{landscape}

\end{document}


after three times compilation you will obtain:

• @DNA... it would be nice from you to accept the right answer... (It is a good practice in the forums we use not to let posts to be unanswered) – koleygr Jan 22 '18 at 14:52
• @koleygr sorry I haven't answered until now, I had a medical emergency. – DNA Jan 23 '18 at 16:16
• I have a problem, It's not working at all, what I get after several compilations is the first column invading all – DNA Jan 23 '18 at 16:40
• "not working" is not helpful. what do you doing? image of table showed in answer is generated with proposed code. so the code is tested and for sure it works. – Zarko Jan 23 '18 at 17:50
• I'm sorry I have been a mess, I finally found out how to upload an image I get when I compile three times the code. Thank you for you help. – DNA Jan 24 '18 at 8:18

1) There was 2 problems in the parameters of columntypes that will be used

First: less columns (6 instead of 7)

Second: r column doesn't take argument of length (except if you redefined it first) I used p columntype that takes argument and breaks the lines automatically (You may try m instead or >{\arraybackslash\raggedleft}p{4cm} if you really need it aligned right)

2) There was an extra separator in last line

\documentclass{article}
\usepackage{lscape}
\usepackage{longtable}
\usepackage{array}
\usepackage{mhchem}
\usepackage{booktabs}
\def\tab{}
\begin{document}
\section{Main structural statistical parameters for the conformers calculated}
\begin{landscape}
\setlength\LTleft{-2cm}
\setlength\LTright{-4cm}
\begin{longtable}{p{4cm} cccccc}
\caption[Chemical shift list of PG-T4 in \ce{H2O}, pH 3.5] {Main structural statistical parameters for the ensemble of the 20 lowest target function conformers calculated for PG-T4, PG-C6C15, PG-C8C13 in \ce{H2O} and 30 mM DPC, pH 3.5}\\
\toprule
&
\multicolumn{3}{c}{\textbf{\ce{H2O}}}   &
\multicolumn{3}{c}{\textbf{30 mM DPC}}   \\
\cmidrule(lr){2-4}
\cmidrule(lr){5-7}
&
\textbf{PG-T4} &
\textbf{PG-C6C15} &
\textbf{PG-C8C13} &
\textbf{PG-T4} &
\textbf{PG-C6C15} &
\textbf{PG-C8C13}
\\

\toprule
&
\textbf{PG-T4}  &
\textbf{PG-C6C15}  &
\textbf{PG-C8C13}&
\textbf{PG-T4}  &
\textbf{PG-C6C15}  &
\textbf{PG-C8C13}\\
\midrule
\bottomrule
\multicolumn{7}{r}{\footnotesize\itshape continue on the next page} % <-- added
\endfoot
\endlastfoot
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Upper Limit distance restraints (from NOEs)             &       &       &       &       &       &       \\
\tab Total  &   numbers &   numbers &   numbers &   numbers &   numbers &   numbers \\
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\bottomrule
\end{longtable}
\end{landscape}
\clearpage
\end{document}

• Thank you so much, my mistake I didn't put my preamble in which I put what "tab" really means. – DNA Jan 22 '18 at 14:18
• Welcome... removing the bold :P (just wanted to see it) – koleygr Jan 22 '18 at 14:44
• Not working, but thank you. I'll keep trying. – DNA Jan 23 '18 at 16:31