1

I have a fairly long table which should go over 2 pages. I used the package longtable to be able to add \pagebreaks. Now, I used another tabular environment in one of the columns since I have a pretty long text and I want it to go over two lines. I compiled the table already, without longtable. It works perfectly. But I now I get a lot of error messages, most of them something like "misplaced alignment tab character ...". Is there another package I could that would allow me to have a table within the other (since I guess that that is the problem) or is there another way to get the text within a column to go over two lines? I am new to LaTeX and just couldn't figure it out. I also hope my MWE works, I have no idea how to get it into code.

\documentclass[12pt,a4paper]{scrreprt}
\usepackage[left=2.5cm,right=2.5cm,top=2.5cm,bottom=2cm,includeheadfoot]{geometry} 
\setlength{\headheight}{15pt}
\usepackage[labelfont=bf,textfont={small}]{caption}
\usepackage{subcaption}
\usepackage{tabularx}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{booktabs}

\begin{document}
\begin{lontable}{ccccc}
    \toprule
    \textbf{Cell Line} &       & \textbf{Sub Clones} & \textbf{Name} & \textbf{Time Point} \\
    \midrule
    \endhead
    \multirow{38}[0]{*}{\textbf{CHO-K1 CTG\_S4 T}} & \multirow{23}[0]{*}{PXP} & \multirow{5}[0]{*}{\begin{tabular}{@{}c@{}}CHO-K1 CTG\_S4 \\ PXP\_S1 2B3 SVC \end{tabular}}& \multirow{5}[0]{*}{SVC3} & T\textsubscript{0} \\
    &       &       &       & T\textsubscript{1} \\
    &       &       &       & T\textsubscript{2} \\
    &       &       &       & T\textsubscript{3} \\
    &       &       &       & T\textsubscript{4} \\
    \cmidrule{3-5} 
    &       & \multirow{5}[0]{*}{\begin{tabularx}{@{}c@{}}CHO-K1 CTG\_S4 \\ PXP\_S2 2.3 SVC\end{tabularx}} & \multirow{5}[0]{*}{SVC5} & T\textsubscript{0} \\
    &       &       &       & T\textsubscript{1} \\
    &       &       &       & T\textsubscript{2} \\
    &       &       &       & T\textsubscript{3} \\
    &       &       &       & T\textsubscript{4} \\
    \cmidrule{3-5}
    &       & \multirow{4}[0]{*}{\begin{tabularx}{@{}c@{}}CHO-K1 CTG\_S4 \\ PXP\_S1 2B3 AAA\end{tabularx}} & \multirow{4}[0]{*}{AAA3} & T\textsubscript{1} \\
    &       &       &       & T\textsubscript{2} \\
    &       &       &       & T\textsubscript{3} \\
    &       &       &       & T\textsubscript{4} \\
    \cmidrule{3-5}
    &       & \multirow{5}[0]{*}{\begin{tabularx}{@{}c@{}}CHO-K1 CTG\_S4 \\PXP\_S1 2.1 AAA\end{tabularx}} & \multirow{5}[0]{*}{AAA4} & T\textsubscript{0} \\
    &       &       &       & T\textsubscript{1} \\
    &       &       &       & T\textsubscript{2} \\
    &       &       &       & T\textsubscript{3} \\
    &       &       &       & T\textsubscript{4} \\
    \cmidrule{3-5}
    &       & \multirow{4}[0]{*}{\begin{tabularx}{@{}c@{}}CHO-K1 CTG\_S4 \\PXP\_S1 2.3 AAA\end{tabularx}} & \multirow{4}[0]{*}{AAA5} & T\textsubscript{1} \\
    &       &       &       & T\textsubscript{2} \\
    &       &       &       & T\textsubscript{3} \\
    &       &       &       & T\textsubscript{4} \\
    \cmidrule{2-5}
    \pagebreak
    & \multirow{5}[0]{*}{PX} & \multirow{5}[0]{*}{\begin{tabularx}{@{}c@{}}CHO-K1 CTG\_S4 \\PX\_S1 3A1\end{tabularx}} & \multirow{5}[0]{*}{VD2} & T\textsubscript{0} \\
    &       &       &       & T\textsubscript{1} \\
    &       &       &       & T\textsubscript{2} \\
    &       &       &       & T\textsubscript{3} \\
    &       &       &       & T\textsubscript{4} \\
    \cmidrule{2-5}
    & \multirow{10}[0]{*}{TT} & \multirow{5}[0]{*}{\begin{tabularx}{@{}c@{}}CHO-K1 CTG\_S4 \\TT\_S1 1A4\end{tabularx}} & \multirow{5}[0]{*}{VD3} & T\textsubscript{0} \\
    &       &       &       & T\textsubscript{1} \\
    &       &       &       & T\textsubscript{2} \\
    &       &       &       & T\textsubscript{3} \\
    &       &       &       & T\textsubscript{4} \\
    \cmidrule{3-5}
    &       & \multirow{5}[0]{*}{\begin{tabularx}{@{}c@{}}CHO-K1 CTG\_S4 \\TT\_S1 3A4\end{tabularx}} & \multirow{5}[0]{*}{VD4} & T\textsubscript{0} \\
    &       &       &       & T\textsubscript{1} \\
    &       &       &       & T\textsubscript{2} \\
    &       &       &       & T\textsubscript{3} \\
    &       &       &       & T\textsubscript{4} \\
    \bottomrule
    \caption{Sample Table CHO-K1 CTG\_S4 T}
    \label{tab:table3}%
\end{lontable}%

\end{document}
  • 1
    unrelated to longtable! your tabularx syntax is incorrect, use tabular not tabularx (tabularx requires an extra argument and an X column, but you want tabular here not tabularx) – David Carlisle Aug 2 '17 at 16:26
1

Environment tabularx is wrong in two ways:

  • The table width argument is missing.
  • A column specifier X is missing.

Solution:

  • tabularx should be replaced by tabular.
  • Also, lontable needs to be replaced by longtable, because the former environment is undefined.
  • Thank you! I feel pretty stupid now for not realizing the g was missing :) – Han Aug 2 '17 at 16:47
0

Some improvements and simplifications, using makecell in the place of a nested tabular:

\documentclass[12pt, a4paper]{scrreprt}
\usepackage[left=2.5cm,right=2.5cm,top=2.5cm,bottom=2cm,includeheadfoot, showframe]{geometry}
\setlength{\headheight}{15pt}
\usepackage[labelfont=bf, textfont={small}]{caption}
\usepackage{subcaption}
\usepackage{tabularx, makecell}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{booktabs}
\renewcommand\theadfont{\normalsize\bfseries}

\begin{document}
\begin{longtable}{ccccc}
   \caption{Sample Table CHO-K1 CTG\_S4 T}
    \label{tab:table3}\\%
\addlinespace
    \toprule
    \thead{Cell Line} & & \thead{Sub Clones} & \thead{Name} & \thead{Time\\ Point} \\
    \midrule
    \endfirsthead
  \multicolumn{5}{c}{\small \tablename~\thetable\enspace (continued)}\\
\addlinespace
    \toprule
    \thead{Cell Line} & & \thead{Sub Clones} & \thead{Name} & \thead{Time\\ Point} \\
    \midrule
    \endhead
\multicolumn{5}{r}{\footnotesize To be continued}
\endfoot
\bottomrule
\endlastfoot
     & \multirow{23}[0]{*}{PXP} & \multirow{5}[0]{*}{\begin{tabular}{@{}c@{}}CHO-K1 CTG\_S4 \\ PXP\_S1 2B3 SVC \end{tabular}}& \multirow{5}[0]{*}{SVC3} & T\textsubscript{0} \\
    & & & & T\textsubscript{1} \\
    & & & & T\textsubscript{2} \\
    & & & & T\textsubscript{3} \\
    & & & & T\textsubscript{4} \\
    \cmidrule{3-5}
    & & \multirow{5}[0]{*}{\makecell{CHO-K1 CTG\_S4 \\ PXP\_S2 2.3 SVC}} & \multirow{5}[0]{*}{SVC5} & T\textsubscript{0} \\
    & & & & T\textsubscript{1} \\
    & & & & T\textsubscript{2} \\
    & & & & T\textsubscript{3} \\
    & & & & T\textsubscript{4} \\
    \cmidrule{3-5}
    & & \multirow{4}[0]{*}{\makecell{CHO-K1 CTG\_S4 \\ PXP\_S1 2B3 AAA}} & \multirow{4}[0]{*}{AAA3} & T\textsubscript{1} \\
    & & & & T\textsubscript{2} \\
    & & & & T\textsubscript{3} \\
    & & & & T\textsubscript{4} \\
    \cmidrule{3-5}
    & & \multirow{5}[0]{*}{\makecell{CHO-K1 CTG\_S4 \\PXP\_S1 2.1 AAA}} & \multirow{5}[0]{*}{AAA4} & T\textsubscript{0} \\
    & & & & T\textsubscript{1} \\
    & & & & T\textsubscript{2} \\
 \textbf{CHO-K1 CTG\_S4 T} & & & & T\textsubscript{3} \\
    & & & & T\textsubscript{4} \\
    \cmidrule{3-5}
    & & \multirow{4}[0]{*}{\makecell{CHO-K1 CTG\_S4 \\PXP\_S1 2.3 AAA}} & \multirow{4}[0]{*}{AAA5} & T\textsubscript{1} \\
    & & & & T\textsubscript{2} \\
    & & & & T\textsubscript{3} \\
    & & & & T\textsubscript{4} \\
    \cmidrule{2-5}
    %\pagebreak
    & \multirow{5}[0]{*}{PX} & \multirow{5}[0]{*}{\makecell{CHO-K1 CTG\_S4 \\PX\_S1 3A1}} & \multirow{5}[0]{*}{VD2} & T\textsubscript{0} \\
    & & & & T\textsubscript{1} \\
    & & & & T\textsubscript{2} \\
    & & & & T\textsubscript{3} \\
    & & & & T\textsubscript{4} \\
    \cmidrule{2-5}
  \pagebreak
    & \multirow{10}[0]{*}{TT} & \multirow{5}[0]{*}{\makecell{CHO-K1 CTG\_S4 \\TT\_S1 1A4}} & \multirow{5}[0]{*}{VD3} & T\textsubscript{0} \\
    & & & & T\textsubscript{1} \\
    & & & & T\textsubscript{2} \\
    & & & & T\textsubscript{3} \\
    & & & & T\textsubscript{4} \\
    \cmidrule{3-5}
    & & \multirow{5}[0]{*}{\makecell{CHO-K1 CTG\_S4 \\TT\_S1 3A4}} & \multirow{5}[0]{*}{VD4} & T\textsubscript{0} \\
    & & & & T\textsubscript{1} \\
    & & & & T\textsubscript{2} \\
    & & & & T\textsubscript{3} \\
    & & & & T\textsubscript{4}
 \end{longtable}%

\end{document}

enter image description here

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.