1

I'm trying to create a table with tabularx, with different column widths:

\documentclass{scrbook}

\usepackage{tabularx}

\newcolumntype{b}{X}
\newcolumntype{s}{>{\hsize=.5\hsize}X}

\begin{document}
    \begin{tabularx}{\linewidth}{sbs}
    \caption[Oligonucleotides]{List of oligonucleotides ...}\\

    \toprule
    \textbf{Number} & \textbf{Sequence} & \textbf{Application}\\[6pt]
    \midrule
    \endfirsthead

    \toprule
    \textbf{Number} & \textbf{Sequence} & \textbf{Application}\\[6pt]
    \midrule
    \endhead

    01247 & CACAGTATTGTCTTTCCCTGCTCCGCCAGGGACCTTGACTTTGAAG & Gibson cloning\\
    01248 & GAAAGTGTCCCTGGAGCCCCCTTCAAAGTCAAG & Gibson cloning\\
    01249 & CTTGACTTTGAAGGGGGCTCCAGGGACACTTTCGTC & Gibson cloning\\
    01250 & GAAAGTGTCCCTGGAGACCCCTTCAAAGTCAAG & Gibson cloning\\
    01251 & CTTGACTTTGAAGGGGTCTCCAGGGACACTTTCGTC & Gibson cloning\\

    \bottomrule
    \end{tabularx}
\end{document}

But I get a hell lot of errors:

\caption outside float. \end{tabularx}
Undefined control sequence. \end{tabularx}
Undefined control sequence. \end{tabularx}
Undefined control sequence. \end{tabularx}
Undefined control sequence. \end{tabularx}
Undefined control sequence. \end{tabularx}
Undefined control sequence. \end{tabularx}
Undefined control sequence. \end{tabularx}
\caption outside float. \end{tabularx}
Undefined control sequence. \end{tabularx}
Undefined control sequence. \end{tabularx}
Undefined control sequence. \end{tabularx}
Undefined control sequence. \end{tabularx}
Undefined control sequence. \end{tabularx}
Undefined control sequence. \end{tabularx}
Undefined control sequence. \end{tabularx}
\caption outside float. \end{tabularx}
Undefined control sequence. \end{tabularx}
Undefined control sequence. \end{tabularx}
Undefined control sequence. \end{tabularx}
Undefined control sequence. \end{tabularx}
Undefined control sequence. \end{tabularx}
Undefined control sequence. \end{tabularx}
Undefined control sequence. \end{tabularx}
\caption outside float. \end{tabularx}
Undefined control sequence. \end{tabularx}
Undefined control sequence. \end{tabularx}
Undefined control sequence. \end{tabularx}
Undefined control sequence. \end{tabularx}
Undefined control sequence. \end{tabularx}
Undefined control sequence. \end{tabularx}
Undefined control sequence. \end{tabularx}
Overfull \hbox (7.21417pt too wide) in paragraph
Underfull \hbox (badness 10000) in paragraph
Overfull \hbox (178.28296pt too wide) in paragraph
Overfull \hbox (76.84334pt too wide) in paragraph
Overfull \hbox (101.40483pt too wide) in paragraph
Overfull \hbox (76.84332pt too wide) in paragraph
Overfull \hbox (100.72044pt too wide) in paragraph
Overfull \hbox (10.95003pt too wide) in paragraph

Does anyone know, how to fix these?

3
  • 3
    \caption doesn't belong in tabularx. – egreg Jul 2 '19 at 9:00
  • You can use \begin{table} \caption{...} \begin{tabularx} instead. – leandriis Jul 2 '19 at 9:02
  • 2
    You are mixing commands of at least three different packages. The macros \toprule, \midrule and \bottomrule come from the booktabs package, while \endhead and \endfirsthead suggest you want to use a longtable from the eponymous package. Please clarify what your are trying to obtain. – campa Jul 2 '19 at 9:17
2

If you want a “long” tabularx, you need to load ltablex.

\documentclass{scrbook}

\usepackage{tabularx,booktabs,seqsplit,ltablex}

\newcolumntype{s}[1]{>{\hsize=#1\hsize}X}

\begin{document}

\begin{tabularx}{\textwidth}{
  @{}
  s{0.5}
  s{2}
  >{\raggedright\arraybackslash}s{0.5}
  @{}
}
\caption[Oligonucleotides]{List of oligonucleotides ...}\\
\toprule
\textbf{Number} & \textbf{Sequence} & \textbf{Application}\\
\midrule
\endfirsthead

\toprule
\textbf{Number} & \textbf{Sequence} & \textbf{Application}\\
\midrule
\endhead

01247 & \seqsplit{CACAGTATTGTCTTTCCCTGCTCCGCCAGGGACCTTGACTTTGAAG} & Gibson cloning\\
01248 & \seqsplit{GAAAGTGTCCCTGGAGCCCCCTTCAAAGTCAAG} & Gibson cloning\\
01249 & \seqsplit{CTTGACTTTGAAGGGGGCTCCAGGGACACTTTCGTC} & Gibson cloning\\
01250 & \seqsplit{GAAAGTGTCCCTGGAGACCCCTTCAAAGTCAAG} & Gibson cloning\\
01251 & \seqsplit{CTTGACTTTGAAGGGGTCTCCAGGGACACTTTCGTC} & Gibson cloning\\
01247 & \seqsplit{CACAGTATTGTCTTTCCCTGCTCCGCCAGGGACCTTGACTTTGAAG} & Gibson cloning\\
01248 & \seqsplit{GAAAGTGTCCCTGGAGCCCCCTTCAAAGTCAAG} & Gibson cloning\\
01249 & \seqsplit{CTTGACTTTGAAGGGGGCTCCAGGGACACTTTCGTC} & Gibson cloning\\
01250 & \seqsplit{GAAAGTGTCCCTGGAGACCCCTTCAAAGTCAAG} & Gibson cloning\\
01251 & \seqsplit{CTTGACTTTGAAGGGGTCTCCAGGGACACTTTCGTC} & Gibson cloning\\
01247 & \seqsplit{CACAGTATTGTCTTTCCCTGCTCCGCCAGGGACCTTGACTTTGAAG} & Gibson cloning\\
01248 & \seqsplit{GAAAGTGTCCCTGGAGCCCCCTTCAAAGTCAAG} & Gibson cloning\\
01249 & \seqsplit{CTTGACTTTGAAGGGGGCTCCAGGGACACTTTCGTC} & Gibson cloning\\
01250 & \seqsplit{GAAAGTGTCCCTGGAGACCCCTTCAAAGTCAAG} & Gibson cloning\\
01251 & \seqsplit{CTTGACTTTGAAGGGGTCTCCAGGGACACTTTCGTC} & Gibson cloning\\
01247 & \seqsplit{CACAGTATTGTCTTTCCCTGCTCCGCCAGGGACCTTGACTTTGAAG} & Gibson cloning\\
01248 & \seqsplit{GAAAGTGTCCCTGGAGCCCCCTTCAAAGTCAAG} & Gibson cloning\\
01249 & \seqsplit{CTTGACTTTGAAGGGGGCTCCAGGGACACTTTCGTC} & Gibson cloning\\
01250 & \seqsplit{GAAAGTGTCCCTGGAGACCCCTTCAAAGTCAAG} & Gibson cloning\\
01251 & \seqsplit{CTTGACTTTGAAGGGGTCTCCAGGGACACTTTCGTC} & Gibson cloning\\
01247 & \seqsplit{CACAGTATTGTCTTTCCCTGCTCCGCCAGGGACCTTGACTTTGAAG} & Gibson cloning\\
01248 & \seqsplit{GAAAGTGTCCCTGGAGCCCCCTTCAAAGTCAAG} & Gibson cloning\\
01249 & \seqsplit{CTTGACTTTGAAGGGGGCTCCAGGGACACTTTCGTC} & Gibson cloning\\
01250 & \seqsplit{GAAAGTGTCCCTGGAGACCCCTTCAAAGTCAAG} & Gibson cloning\\
01251 & \seqsplit{CTTGACTTTGAAGGGGTCTCCAGGGACACTTTCGTC} & Gibson cloning\\
01247 & \seqsplit{CACAGTATTGTCTTTCCCTGCTCCGCCAGGGACCTTGACTTTGAAG} & Gibson cloning\\
01248 & \seqsplit{GAAAGTGTCCCTGGAGCCCCCTTCAAAGTCAAG} & Gibson cloning\\
01249 & \seqsplit{CTTGACTTTGAAGGGGGCTCCAGGGACACTTTCGTC} & Gibson cloning\\
01250 & \seqsplit{GAAAGTGTCCCTGGAGACCCCTTCAAAGTCAAG} & Gibson cloning\\
01251 & \seqsplit{CTTGACTTTGAAGGGGTCTCCAGGGACACTTTCGTC} & Gibson cloning\\
01247 & \seqsplit{CACAGTATTGTCTTTCCCTGCTCCGCCAGGGACCTTGACTTTGAAG} & Gibson cloning\\
01248 & \seqsplit{GAAAGTGTCCCTGGAGCCCCCTTCAAAGTCAAG} & Gibson cloning\\
01249 & \seqsplit{CTTGACTTTGAAGGGGGCTCCAGGGACACTTTCGTC} & Gibson cloning\\
01250 & \seqsplit{GAAAGTGTCCCTGGAGACCCCTTCAAAGTCAAG} & Gibson cloning\\
01251 & \seqsplit{CTTGACTTTGAAGGGGTCTCCAGGGACACTTTCGTC} & Gibson cloning\\
01247 & \seqsplit{CACAGTATTGTCTTTCCCTGCTCCGCCAGGGACCTTGACTTTGAAG} & Gibson cloning\\
01248 & \seqsplit{GAAAGTGTCCCTGGAGCCCCCTTCAAAGTCAAG} & Gibson cloning\\
01249 & \seqsplit{CTTGACTTTGAAGGGGGCTCCAGGGACACTTTCGTC} & Gibson cloning\\
01250 & \seqsplit{GAAAGTGTCCCTGGAGACCCCTTCAAAGTCAAG} & Gibson cloning\\
01251 & \seqsplit{CTTGACTTTGAAGGGGTCTCCAGGGACACTTTCGTC} & Gibson cloning\\
01247 & \seqsplit{CACAGTATTGTCTTTCCCTGCTCCGCCAGGGACCTTGACTTTGAAG} & Gibson cloning\\
01248 & \seqsplit{GAAAGTGTCCCTGGAGCCCCCTTCAAAGTCAAG} & Gibson cloning\\
01249 & \seqsplit{CTTGACTTTGAAGGGGGCTCCAGGGACACTTTCGTC} & Gibson cloning\\
01250 & \seqsplit{GAAAGTGTCCCTGGAGACCCCTTCAAAGTCAAG} & Gibson cloning\\
01251 & \seqsplit{CTTGACTTTGAAGGGGTCTCCAGGGACACTTTCGTC} & Gibson cloning\\
01247 & \seqsplit{CACAGTATTGTCTTTCCCTGCTCCGCCAGGGACCTTGACTTTGAAG} & Gibson cloning\\
01248 & \seqsplit{GAAAGTGTCCCTGGAGCCCCCTTCAAAGTCAAG} & Gibson cloning\\
01249 & \seqsplit{CTTGACTTTGAAGGGGGCTCCAGGGACACTTTCGTC} & Gibson cloning\\
01250 & \seqsplit{GAAAGTGTCCCTGGAGACCCCTTCAAAGTCAAG} & Gibson cloning\\
01251 & \seqsplit{CTTGACTTTGAAGGGGTCTCCAGGGACACTTTCGTC} & Gibson cloning\\
01247 & \seqsplit{CACAGTATTGTCTTTCCCTGCTCCGCCAGGGACCTTGACTTTGAAG} & Gibson cloning\\
01248 & \seqsplit{GAAAGTGTCCCTGGAGCCCCCTTCAAAGTCAAG} & Gibson cloning\\
01249 & \seqsplit{CTTGACTTTGAAGGGGGCTCCAGGGACACTTTCGTC} & Gibson cloning\\
01250 & \seqsplit{GAAAGTGTCCCTGGAGACCCCTTCAAAGTCAAG} & Gibson cloning\\
01251 & \seqsplit{CTTGACTTTGAAGGGGTCTCCAGGGACACTTTCGTC} & Gibson cloning\\

\bottomrule
\end{tabularx}

\end{document}

You can use \hsize=<fraction>\hsize, but the sum of the fractional values should equal the number of X columns.

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.