3

I have a problem with a specific tabularx I'm using in my master thesis.

I produced this code:

\documentclass[headsepline,titlepage,oneside,12pt]{report}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{amsbsy}
\usepackage{mathtools}
\usepackage{tabularx}
\usepackage{textcomp}
\usepackage{multirow}

\begin{document}

\begin{table}[ht!]
\centering
\newcolumntype{C}{>{\centering\arraybackslash}X}%
\newcolumntype{L}{>{\raggedright\arraybackslash}X}%

    \begin{tabularx}{\textwidth}{|L|C|*{6}{C|}}\firsthline
    \multirow{2}{*}{\bfseries Integrationsart}  &   \multirow{2}{*}{\bfseries Berechnung}   &   \multicolumn{6}{c|}{\bfseries Skala (0 - 5)}\\\cline{3-8}
                                                &                                           &   0   &   1   &   2   &   3   &   4   &   5\\\hline
    Datenintegration                    &   $BK2 + BK5_{admin. Anmeld.} + BK5_{Abrechnung}$ & $>$8 & 7 - 8 & 5 - 6 & 3 - 4 & 1 - 2 & 0\\\hline
    Prozessintegration                  &   $BK4_{admin. Anmeld.} + BK4_{Abrechnung} + BK5_{admin. Anmeld.} + BK5_{Abrechnung}$ & $>$10 & 9 - 10 & 7 - 8 & 5 - 6 & 3 - 4 & $\leq$2\\\hline
    \end{tabularx}

\caption{Abbildung der Wertebereiche der Bewertungskriterien auf die Skala der Integrationsqualitäten}
\label{tab:BKtoSpider}
\end{table}

\end{document}

but the PDF layout comes out like this: PDF layout of tabularx table

I have no idea why the Skala columns are much wider than the numbers within and why the column "Berechnung" has no space.

Any ideas?

I thank you guys for your time and I'm looking forward to your suggestions for my first question on this platform. ;-)

Peter

4
  • 1
    What's with your rush to accept the first answer almost as soon as it's posted? On this site, it's generally recommended to wait a few hours before accepting one of the answers. Otherwise, you'll seriously risk discourage others from posting a competing answer.
    – Mico
    Commented Feb 28, 2016 at 18:33
  • Okay, thanks for that advice. I just tried and liked it, didn't know I can't accept more than one answer. I'll keep that in mind for the future.
    – Peter
    Commented Feb 28, 2016 at 18:56
  • 2
    Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem.
    – Holene
    Commented Feb 28, 2016 at 18:57
  • Thanks for the advice, @Holene. Didn't know the documentclass and begin-end document is necessary, but it totally makes sence since it's just a copy&paste for helpers to have an eye on it.
    – Peter
    Commented Feb 28, 2016 at 19:01

2 Answers 2

1

You specified a width, but the content was too wide. You do not want tabularx for data tables, it is designed for controlling line breaks in tables of text. Also never use math italic for multi-letter words.

Something like this, although it may be too wide, you gave no indication of your page size.

\documentclass{article}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{amsbsy}
\usepackage{mathtools}
\usepackage{tabularx}
\usepackage{textcomp}
\usepackage{multirow}

\begin{document}
\begin{table}[htp]
\centering

    \begin{tabular}{|l|>{\centering}p{3cm}|*{6}{c|}}\firsthline
    \multirow{2}{*}{\bfseries Integrationsart}  &  
 \multirow{2}{*}{\bfseries Berechnung}   &   \multicolumn{6}{c|}{\bfseries Skala (0 - 5)}\\\cline{3-8}
                                                &                                           &   0   &   1   &   2   &   3   &   4   &   5\\\hline
    Datenintegration                    &   $BK2 + BK5_{\textrm{admin. Anmeld.}} + BK5_{\textrm{Abrechnung}}$ & $>$8 & 7 - 8 & 5 - 6 & 3 - 4 & 1 - 2 & 0\\\hline
    Prozessintegration                  &   $BK4_{\textrm{admin. Anmeld.}} + BK4_{\textrm{Abrechnung}} + BK5_{\textrm{admin. Anmeld.}} + BK5_{\textrm{Abrechnung}}$ & $>$10 & 9 - 10 & 7 - 8 & 5 - 6 & 3 - 4 & $\leq$2\\\hline
    \end{tabular}

\caption{Abbildung der Wertebereiche der Bewertungskriterien auf die Skala der Integrationsqualitäten}
\label{tab:BKtoSpider}
\end{table}

\end{document}
9
  • Nice! Thank you, David! I'll figure out the little sizing know...
    – Peter
    Commented Feb 28, 2016 at 18:24
  • There's a good chance that this table will be quite a bit wider than the text block.
    – Mico
    Commented Feb 28, 2016 at 18:32
  • As I configurate the widths of the Skala columns, I found out I can't use *{6}{>{\centering}m{0.9cm}, just *{6}{m{0.9cm}. Do you know why I can't use >{\centering} in the multiple column definition?
    – Peter
    Commented Feb 28, 2016 at 18:46
  • 1
    Have you missed out a } (you have in the code fragment in the comment) Commented Feb 28, 2016 at 19:10
  • ah, no. That was a c&p error. :-P
    – Peter
    Commented Feb 28, 2016 at 19:23
1

If you want to stay with a tabularx setup, you need to widen the second column and reduce the widths of columns 3 to 8. (Calculation hint: 2.6+6*0.7333=7= # of columns whose width is either being increased or decreased.)

You also need to break up the long quasi-math expressions in the second column so that LateX can actually insert linebreaks. You also need to do something about the first column so that hyphenation is permissible on the first (and, as it turns out, only) words in each cell; I suggest you insert \hspace{0pt} for this purpose. Talking about hyphenation, it's probably also a good idea to load the babel package and provide a few more hyphenation points.

enter image description here

\documentclass{article}
\usepackage{amsfonts,amssymb,amsthm,amsbsy}
\usepackage{mathtools}
\usepackage[ngerman]{babel}
\hyphenation{inte-gra-tionsart daten-integra-tion prozess-integra-tion}
\usepackage{tabularx}
\newcolumntype{C}{>{\centering\arraybackslash\hspace{0pt}}X}%
\newcolumntype{L}{>{\raggedright\arraybackslash\hspace{0pt}}X}%

\usepackage{textcomp}
\usepackage{multirow}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{table}[ht!]
\setlength{\tabcolsep}{2pt} % default value: 6pt
\begin{tabularx}{\textwidth}{|L|>{\hsize=2.6\hsize}L|*{6}{>{\hsize=0.7333\hsize}C|}}
\firsthline
\bfseries Integrationsart  &   \bfseries Berechnung   &   \multicolumn{6}{c|}{\bfseries Skala (0 -- 5)}\\
\cline{3-8}
 & & 0 & 1 & 2 & 3 & 4 & 5\\
 \hline
Datenintegration  &   
BK2 $+$ 
BK5$_{\text{admin. Anmeld.}}$ $+$ 
BK5$_{\text{Abrechnung}}$ & 
$>8$ & 7 -- 8 & 5 -- 6 & 3 -- 4 & 1 -- 2 & 0\\
\hline
Prozessintegration&   
BK4$_{\text{admin. Anmeld.}}$ $+$ 
BK4$_{\text{Abrechnung}}$ $+$ 
BK5$_{\text{admin. Anmeld.}}$ $+$ 
BK5$_{\text{Abrechnung}}$ & 
$>10 $& 9 -- 10 & 7 -- 8 & 5 -- 6 & 3 -- 4 & $\leq2$\\
\hline
\end{tabularx}

\caption{Abbildung der Wertebereiche der Bewertungskriterien auf die Skala der Integrationsqualitäten}
\label{tab:BKtoSpider}
\end{table}
\end{document}

Addendum, posted after the OP indicated that the report document class is in use: It's probably a good idea not to allow line breaks in the words in the first column. Switching the column type from L to l and getting rid of all vertical bars and employing the rule-drawing macros of the booktabs package produces the following, more "open" look for the table:

enter image description here

\documentclass[headsepline,titlepage,oneside,12pt]{report}
\usepackage{amsfonts,amssymb,amsthm,amsbsy,mathtools}
\usepackage[ngerman]{babel}

\usepackage{tabularx}
\newcolumntype{C}{>{\centering\arraybackslash\hspace{0pt}}X}
\newcolumntype{L}{>{\raggedright\arraybackslash\hspace{0pt}}X}

\usepackage{booktabs}
\usepackage[utf8]{inputenc}

\begin{document}

\begin{table}[ht!]
\setlength{\tabcolsep}{2pt} % default value: 6pt
\begin{tabularx}{\textwidth}{@{} l >{\hsize=2.6\hsize}L *{6}{>{\hsize=0.7333\hsize}C} @{}}
\toprule
Integrationsart & Berechnung & \multicolumn{6}{c@{}}{Skala (0--5)}\\
\cmidrule(l){3-8}
 & & 0 & 1 & 2 & 3 & 4 & 5\\
\midrule
Datenintegration  &   
BK2\,$+$ 
BK5$_{\text{admin. Anmeld.}}$\,$+$ 
BK5$_{\text{Abrechnung}}$ & 
$>$8 & 7--8 & 5--6 & 3--4 & 1--2 & 0\\
\addlinespace
Prozessintegration&   
BK4$_{\text{admin. Anmeld.}}$\,$+$ 
BK4$_{\text{Abrechnung}}$\,$+$ 
BK5$_{\text{admin. Anmeld.}}$\,$+$ 
BK5$_{\text{Abrechnung}}$ & 
$>$10& 9--10 & 7--8 & 5--6 & 3--4 & $\leq$2\\
\bottomrule
\end{tabularx}

\caption{Abbildung der Wertebereiche der Bewertungskriterien 
auf die Skala der Integrationsqualitäten}
\label{tab:BKtoSpider}
\end{table}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .