1

I am trying to create an appealing table. So far this is my result:

The current table

As you can see the table does not look right. For example the work Komplexität is not hyphenated right. And the column titles Kriterien and Gewichtungsfaktor are not on the same line as the rest of the column titles.

Has somebody a tip how to fix those mistakes, or how to convert the whole table to a booktabs table?

MWE:

%!TEX TS-program = lualatex

\documentclass[
    a4paper,
    oneside,
    titlepage=firstiscover
]{scrartcl}

\usepackage[
onehalfspacing
]{setspace}
\usepackage{polyglossia}
\usepackage{float}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{colortbl}
\usepackage{ragged2e}
\usepackage{rotating}
\usepackage{booktabs}

\setmainlanguage{german}

% rotate text in table heads
\newcommand\rotateText[2]{\rotatebox{90}{\parbox{#2cm}{\raggedright#1}}}

% Tabularx cells
\newcolumntype{R}[1]{>{\raggedleft\hsize=#1\hsize\arraybackslash}X}%
\newcolumntype{L}[1]{>{\raggedright\hsize=#1\hsize\arraybackslash}X}%
\newcolumntype{C}[1]{>{\centering\hsize=#1\hsize\arraybackslash}X}

\usepackage{hyphenat}

\hyphenation{Um-setz-bar-keit Kom-ple-xi-tät}

\begin{document}

    \begin{table}[ht]
        \centering
        \begin{tabularx}{\textwidth}{C{0.1}L{0.39}C{0.06}|C{0.06}>{\columncolor[gray]{0.9}}C{0.06}|C{0.06}>{\columncolor[gray]{0.9}}C{0.06}|C{0.06}>{\columncolor[gray]{0.9}}C{0.06}|C{0.06}>{\columncolor[gray]{0.9}}C{0.06}}
            & \multirow{2}{*}{\rotateText{\textbf{Kriterien}}{4}} & \multirow{2}{*}{\rotateText{\textbf{Gewichtungsfaktor}}{4}} & \multicolumn{2}{l}{\textbf{RSS}} & \multicolumn{2}{l}{\textbf{FP}} & \multicolumn{2}{l}{\textbf{Prox.}} & \multicolumn{2}{l}{\textbf{Opt.}} \\
            & & & \rotateText{Erfüllungsgrad}{3.18} & \rotateText{Werte}{3.18} & \rotateText{Erfüllungsgrad}{3.18} & \rotateText{Werte}{3.18} & \rotateText{Erfüllungsgrad}{3.18} & \rotateText{Werte}{3.18} & \rotateText{Erfüllungsgrad}{3.18} & \rotateText{Werte}{3.18} \\
            \toprule
            \multirow{3}{*}{\rotateText{Komplexität}{1.75}} & Installationsaufwand & 4 & 4 & 16 & 2 & 8 & 3 & 12 & 5 & 20 \\
            & Hardware & 2 & 4 & 8 & 4 & 8 & 4 & 8 & 5 & 10 \\
            & Software & 2 & 4 & 8 & 3 & 6 & 5 & 10 & 5 & 10 \\
            \midrule
            \multirow{3}{*}{\rotateText{Kosten}{0.5}} & Installation & 2 & 3 & 6 & 2 & 4 & 4 & 8 & 5 & 10 \\
            & Anzahl Sensoren & 4 & 3 & 6 & 2 & 4 & 4 & 8 & 5 & 10 \\
            \midrule
            & Energieverbrauch & 4 & 3 & 12 & 3 & 12 & 4 & 16 & 5 & 20 \\
            \\[-1em]
            & \multicolumn{3}{l}{Punkte} & 62 & & 58 & & 66 & & 90 \\
            & \multicolumn{3}{l}{Wirtschaftliche Wertigkeit} & 0.69 & & 0.64 & & 0.73 & & 1 \\
        \end{tabularx}
    \end{table}


\end{document}
  • Why is Komplexität not hyphenated right? You gave a too wide width... – TeXnician Oct 31 '17 at 16:02
  • And please do not load booktabs if you ignore all advice the manual tries to give. Your table won't look better with booktabs rules and vertical lines. – TeXnician Oct 31 '17 at 16:04
2

I would recommend thinking twice about the use of colour and actually making use of the facilities of booktabs.

Consider as a starting point (or if @TeXnician's changes in his answer - which admittedly look better - are too radical): enter image description here

%!TEX TS-program = lualatex

\documentclass[
    a4paper,
    oneside,
    titlepage=firstiscover
]{scrartcl}

\usepackage[onehalfspacing]{setspace}
\usepackage{polyglossia}
\usepackage{float}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{colortbl}
\usepackage{ragged2e}
\usepackage{rotating}
\usepackage{booktabs}

\setmainlanguage{german}

% rotate text in table heads
\newcommand\rotateText[2]{\rotatebox{90}{\parbox{#2cm}{\raggedright#1}}}

% Tabularx cells
\newcolumntype{R}[1]{>{\raggedleft\hsize=#1\hsize\arraybackslash}X}%
\newcolumntype{L}[1]{>{\raggedright\hsize=#1\hsize\arraybackslash}X}%
\newcolumntype{C}[1]{>{\centering\hsize=#1\hsize\arraybackslash}X}

\usepackage{hyphenat}

\hyphenation{Um-setz-bar-keit Kom-ple-xi-tät}

\begin{document}

    \begin{table}[ht]
        \centering
        \begin{tabularx}{\textwidth}{%
            C{0.1}%
            L{0.39}%
            C{0.06}%
            C{0.06}%
            C{0.06}%
            C{0.06}%
            C{0.06}%
            C{0.06}%
            C{0.06}%
            C{0.06}%
            C{0.06}%
        }
            \toprule
            & \multirow{2}{*}{\rotateText{\textbf{Kriterien}}{3.8}} & \multirow{2}{*}{\rotateText{\textbf{Gewichtungsfaktor}}{3.8}} & \multicolumn{2}{c}{\textbf{RSS}} & \multicolumn{2}{c}{\textbf{FP}} & \multicolumn{2}{c}{\textbf{Prox.}} & \multicolumn{2}{c}{\textbf{Opt.}} \\
            \cmidrule(lr){4-5}\cmidrule(lr){6-7}\cmidrule(lr){8-9}\cmidrule(lr){10-11}
            & & & \rotateText{Erfüllungsgrad}{3.18} & \rotateText{Werte}{3.18} & \rotateText{Erfüllungsgrad}{3.18} & \rotateText{Werte}{3.18} & \rotateText{Erfüllungsgrad}{3.18} & \rotateText{Werte}{3.18} & \rotateText{Erfüllungsgrad}{3.18} & \rotateText{Werte}{3.18} \\
            \midrule
            \multirow{3}{*}{\rotateText{Komplexität}{1.4}} & Installationsaufwand & 4 & 4 & 16 & 2 & 8 & 3 & 12 & 5 & 20 \\
            & Hardware & 2 & 4 & 8 & 4 & 8 & 4 & 8 & 5 & 10 \\
            & Software & 2 & 4 & 8 & 3 & 6 & 5 & 10 & 5 & 10 \\
            \cmidrule(lr){1-11}
            \multirow{3}{*}{\rotateText{Kosten}{0.4}} & Installation & 2 & 3 & 6 & 2 & 4 & 4 & 8 & 5 & 10 \\
            & Anzahl Sensoren & 4 & 3 & 6 & 2 & 4 & 4 & 8 & 5 & 10 \\
            \cmidrule(lr){1-11}
            & Energieverbrauch & 4 & 3 & 12 & 3 & 12 & 4 & 16 & 5 & 20 \\
            \midrule
            & \multicolumn{3}{l}{Punkte} & 62 & & 58 & & 66 & & 90 \\
            & \multicolumn{3}{l}{Wirtschaftliche Wertigkeit} & 0.69 & & 0.64 & & 0.73 & & 1 \\
            \bottomrule
        \end{tabularx}
    \end{table}


\end{document}
  • Actually I like this layout as it preserves more of the basic structure, but manual factors are horrible (or spooky as it's Halloween)... – TeXnician Oct 31 '17 at 16:41
  • @TeXnician 1st: agreed manual factors are horrible - some could be weeded out here. 2nd: on consideration, I find your layout more logical, with the 'summary' columns appearing more naturally to the right. – greyshade Oct 31 '17 at 16:44
3

what is fancy and what is aesthetic (regarding table design) ... is very personal opinions :-), so i only rewrote your code to be more simple and gives similar result obtained with yours mwe:

enter image description here

(red lines indicate text margins). in mwe below is used makecell package for column headers, booktabs only for determine \cmidrule, determination of columns is simplified, etc

\documentclass[
    a4paper,
    oneside,
    titlepage=firstiscover
]{scrartcl}

\usepackage[onehalfspacing]{setspace}
\usepackage{polyglossia}
\usepackage{rotating}
\usepackage{booktabs, makecell, tabularx}
\renewcommand\theadfont{\bfseries}

\usepackage[table]{xcolor}
\usepackage{ragged2e}

\usepackage{hyphenat}

\hyphenation{Um-setz-bar-keit Kom-ple-xi-tät}
%-------------------------------- show page layout, only for test
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
    \begin{table}
\settowidth\rotheadsize{\theadfont Gewichtungsfaktor }
\setlength\tabcolsep{4pt}
\renewcommand\arraystretch{1.2}
\renewcommand{\belowrulesep}{0pt}
\centering
\begin{tabularx}{\linewidth}{@{}        l l
                                        c c
    >{\columncolor{gray!10}\centering}  X c
    >{\columncolor{gray!10}\centering}  X c
    >{\columncolor{gray!10}\centering}  X c
    >{\columncolor{gray!10}[\tabcolsep][0pt]\centering\arraybackslash}  X
                            @{}}
    \Xhline{1pt}
    &   &   \multicolumn{3}{c}{\textbf{RSS}}
                &   \multicolumn{2}{c}{\textbf{FP}}
                    &   \multicolumn{2}{c}{\textbf{Prox.}}
                        &   \multicolumn{2}{c}{\textbf{Opt.}}                       \\
    \cmidrule(l{2.5pt}){4-5}
    \cmidrule(l{2.5pt}){6-7}
    \cmidrule(l{2.5pt}){8-9}
    \cmidrule(l{2.5pt}){10-11}
    &   \rothead{\textbf{Kriterien}}
        &   \rothead{\textbf{Gewichtungsfaktor}}
            &   \rothead{Erfüllungsgrad}
                &   \rothead{Werte}
                    &   \rothead{Erfüllungsgrad}
                        &   \rothead{Werte}
                            &   \rothead{Erfüllungsgrad}
                                &   \rothead{Werte}
                                    &   \rothead{Erfüllungsgrad}
                                        &   \rothead{Werte}                         \\
    \Xhline{0.75pt}
\thead[l]{Komplexität}
    &   Installationsaufwand    & 4 & 4 & 16    & 2 &  8    & 3 & 12    & 5 & 20    \\
    &   Hardware                & 2 & 4 &  8    & 4 &  8    & 4 &  8    & 5 & 10    \\
    &   Software                & 2 & 4 &  8    & 3 &  6    & 5 & 10    & 5 & 10    \\
    \hline
\thead[l]{Kosten}
    &   Installation            & 2 & 3 &  6    & 2 &  4    & 4 &  8    & 5 & 10    \\
    &   Anzahl Sensoren         & 4 & 3 &  6    & 2 &  4    & 4 &  8    & 5 & 10    \\
    &   Energieverbrauch        & 4 & 3 & 12    & 3 & 12    & 4 & 16    & 5 & 20    \\

    \hline
    & \multicolumn{3}{l}{Punkte}        & 62    &   & 58    &   & 66    &   & 90    \\
    & \multicolumn{3}{l}{Wirtschaftliche Wertigkeit}
                                        & 0.69  &   & 0.64  &   & 0.73  &   & 1     \\
    \Xhline{0.75pt}
\end{tabularx}
    \end{table}
\end{document}

edit: after reading TeXnician comment i see that above mwe wasn't complete. now i correct this. in correction i consider mentioned comment too.

  • Do you really think that "Gewichtungsfaktor" belogs to RSS? – TeXnician Nov 1 '17 at 8:32
  • @TeXnician, no, i haven't any clue about meaning of tables content :-(. it should be simple to exclude it with change \cmidrule(l{1pt}r{1pt}){3-5} to \cmidrule(l{1pt}r{1pt}){4-5}. now this seems this more logical to me too :-). i will correct this asap and also add missing code (copy-past problem). – Zarko Nov 1 '17 at 10:32
2

I would swap columns and rows and start to utilize booktabs as well as rotating. As a starter:

table

%!TEX TS-program = lualatex

\documentclass[
    a4paper,
    oneside,
    titlepage=firstiscover
]{scrartcl}

\usepackage[
onehalfspacing
]{setspace}
\usepackage{polyglossia}
\usepackage{float}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{colortbl}
\usepackage{ragged2e}
\usepackage{rotating}
\usepackage{booktabs}

\setmainlanguage{german}

% rotate text in table heads
\newcommand\rotateText[2]{\rotatebox{90}{\parbox{#2cm}{\raggedright#1}}}

% Tabularx cells
\newcolumntype{R}[1]{>{\raggedleft\hsize=#1\hsize\arraybackslash}X}%
\newcolumntype{L}[1]{>{\raggedright\hsize=#1\hsize\arraybackslash}X}%
\newcolumntype{C}[1]{>{\centering\hsize=#1\hsize\arraybackslash}X}

\usepackage{hyphenat}

\hyphenation{Um-setz-bar-keit Kom-ple-xi-tät}

\begin{document}

    \begin{table}[ht]
        \centering
        \begin{tabularx}{\textwidth}{C{0.1}L{0.39}C{0.06}|C{0.06}>{\columncolor[gray]{0.9}}C{0.06}|C{0.06}>{\columncolor[gray]{0.9}}C{0.06}|C{0.06}>{\columncolor[gray]{0.9}}C{0.06}|C{0.06}>{\columncolor[gray]{0.9}}C{0.06}}
            & \multirow{2}{*}{\rotateText{\textbf{Kriterien}}{4}} & \multirow{2}{*}{\rotateText{\textbf{Gewichtungsfaktor}}{4}} & \multicolumn{2}{l}{\textbf{RSS}} & \multicolumn{2}{l}{\textbf{FP}} & \multicolumn{2}{l}{\textbf{Prox.}} & \multicolumn{2}{l}{\textbf{Opt.}} \\
            & & & \rotateText{Erfüllungsgrad}{3.18} & \rotateText{Werte}{3.18} & \rotateText{Erfüllungsgrad}{3.18} & \rotateText{Werte}{3.18} & \rotateText{Erfüllungsgrad}{3.18} & \rotateText{Werte}{3.18} & \rotateText{Erfüllungsgrad}{3.18} & \rotateText{Werte}{3.18} \\
            \toprule
            \multirow{3}{*}{\rotateText{Komplexität}{1.75}} & Installationsaufwand & 4 & 4 & 16 & 2 & 8 & 3 & 12 & 5 & 20 \\
            & Hardware & 2 & 4 & 8 & 4 & 8 & 4 & 8 & 5 & 10 \\
            & Software & 2 & 4 & 8 & 3 & 6 & 5 & 10 & 5 & 10 \\
            \midrule
            \multirow{3}{*}{\rotateText{Kosten}{0.5}} & Installation & 2 & 3 & 6 & 2 & 4 & 4 & 8 & 5 & 10 \\
            & Anzahl Sensoren & 4 & 3 & 6 & 2 & 4 & 4 & 8 & 5 & 10 \\
            \midrule
            & Energieverbrauch & 4 & 3 & 12 & 3 & 12 & 4 & 16 & 5 & 20 \\
            \\[-1em]
            & \multicolumn{3}{l}{Punkte} & 62 & & 58 & & 66 & & 90 \\
            & \multicolumn{3}{l}{Wirtschaftliche Wertigkeit} & 0.69 & & 0.64 & & 0.73 & & 1 \\
        \end{tabularx}
    \end{table}

        \begin{sidewaystable}
            \centering
            \renewcommand{\arraystretch}{1.1}
            \begin{tabularx}{\textwidth}{l*{8}{X}}
                \toprule & \multicolumn{3}{c}{Komplexität} &  \multicolumn{2}{c}{Kosten} & & &\\\cmidrule(lr){2-4}\cmidrule(lr){5-6}
                Produkt & Installationsaufwand (4) & Hardware (2) & Software (2) & Installation (2) & Anzahl Sensoren (4) & Energieverbrauch (4) & Punkte & Wirtsch. Wertigkeit\\\midrule
                RSS\\
                \hskip.5em Erfüllungsgrad & 4 & 4 & 4 & 3 & 3 & 3 & &\\
                \hskip.5em Werte & 16 & 8 & 8 & 6 & 6 & 12 & 62 & 0.69\\\addlinespace
                RSS\\
                \hskip.5em Erfüllungsgrad & 4 & 4 & 4 & 3 & 3 & 3 & &\\
                \hskip.5em Werte & 16 & 8 & 8 & 6 & 6 & 12 & 62 & 0.69\\\addlinespace
                RSS\\
                \hskip.5em Erfüllungsgrad & 4 & 4 & 4 & 3 & 3 & 3 & &\\
                \hskip.5em Werte & 16 & 8 & 8 & 6 & 6 & 12 & 62 & 0.69\\\bottomrule
            \end{tabularx}\medbreak
            Zahlen in Klammern bezeichnen die Gewichtungsfaktoren der einzelnen Komponenten zur Gesamtpunktzahl.
        \end{sidewaystable}
\end{document}
  • Looks great!!!! – user36296 Oct 31 '17 at 16:24
  • It looks great :) but I am not sure if we are allowed to put a table sideways. – Pascal Nov 1 '17 at 12:37

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.