0

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} 
\\

\endfirsthead
\toprule
         & &
        \textbf{PG-T4}  & 
        \textbf{PG-C6C15}  & 
        \textbf{PG-C8C13}& 
        \textbf{PG-T4}  & 
        \textbf{PG-C6C15}  & 
        \textbf{PG-C8C13}
        \\
\midrule
\endhead
\endhead
\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.

enter image description here

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

  • 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
1

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}
\renewcommand\theadfont{\small\bfseries}
\renewcommand\theadgape{}
\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
    &
\multicolumn{3}{c}{\thead{\ce{H2O}}}    &   \multicolumn{3}{c}{\thead{30 mM DPC}}   \\
    \cmidrule(lr){2-4}  \cmidrule(lr){5-7}
        & {\thead{PG-T4}}   & {\thead{PG-C6C15}}    & {\thead{PG-C8C13}}
        & {\thead{PG-T4}}   & {\thead{PG-C6C15}}    & {\thead{PG-C8C13}}            \\
    \midrule
\endfirsthead
\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
    &
\multicolumn{3}{c}{\thead{\ce{H2O}}}    &   \multicolumn{3}{c}{\thead{30 mM DPC}}   \\
    \cmidrule(lr){2-4}  \cmidrule(lr){5-7}
        & {\thead{PG-T4}}   & {\thead{PG-C6C15}}    & {\thead{PG-C8C13}}
        & {\thead{PG-T4}}   & {\thead{PG-C6C15}}    & {\thead{PG-C8C13}}            \\
    \midrule
\endhead
    \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:

enter image description here

  • @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
  • 1
    "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

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} 
\\

\endfirsthead
\toprule
         & 
        \textbf{PG-T4}  & 
        \textbf{PG-C6C15}  & 
        \textbf{PG-C8C13}& 
        \textbf{PG-T4}  & 
        \textbf{PG-C6C15}  & 
        \textbf{PG-C8C13}\\
\midrule
\endhead
\endhead
\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

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.