2

I have a Problem with tabularx. I Need to put a larger text inside a pretty tightly packed table. The result Looks like this: enter image description here

As you see, the text kind of bleeds into the next row. Additionally I cant find the reason, why the row with "Kaltstart" in it is twice as big as the others. My Minimal Example:

\documentclass[a4paper,12pt]{scrreprt}       



\usepackage{multirow}
\usepackage{tabularx}
\newcolumntype{s}{>{\hsize=.17\hsize}X}
\newcolumntype{g}{>{\hsize=.5\hsize}X}
\renewcommand\arraystretch{1.2}


\begin{document}

 \begin{table}
    \caption{caption}
    \begin{tabularx}{\textwidth}{|g|X|g|g|s|s|s|s|}
  \hline
A & & B & C & D & E & F & G \\ \hline
A & B & & C & 373 & 361 & 679 & 676 \\ \cline{2-8}

&A&  & B & 321 & 321 & 660 & 660 \\ \cline{2-8}

&A& & B & 210 & 210 & 245 & 245 \\\hline

Start-Parameter &\multirow{3}{\linewidth}{Zeit zw. Anforderung und techn. Mindestlast bei Anfahrt}
& Kaltstart &min &500 &500 &515 &515 \\ \cline{3-8}
& &A&min &470 &470 &433 &433 \\ \cline{3-8}
& &B &min &470 &470 &380 &380 \\ \cline{2-8}

&\multirow{4}{\linewidth}{Zeit zw. Synchronisation und techn. Mindestlast}
& Kaltstart &min &500 &500 &515 &515 \\ \cline{3-8}
& & A &min &470 &470 &433 &433 \\ \cline{3-8}
& & B &min &470 &470 &380 &380 \\ \cline{2-8}

&\multirow{3}{\linewidth}{Duchschnittsgradient zw. Synchronisation und technischer Mindestlast}
& Kaltstart &MW/min &2,6 &2,6 &4,5 &4,5 \\ \cline{3-8}
& & A &MW/min &3,5 &3,5 &10,7 &10,7 \\ \cline{3-8}
& & B &MW/min &3,5 &3,5 &12,3 &12,3 \\ \hline
\end{tabularx}
\label{tab:meinetabelle}
\end{table}


\end{document}

This example is sadly not as good looking as I hoped it to be. Advice to make it easier to read is very welcome!

Note: ABCDEFG being placeholders for blacked out data.

10
  • Welcome to TeX SX! This code is not compilable: the m column type is already defined and requires a parameter.
    – Bernard
    Jun 14, 2018 at 6:39
  • please test the code produces the image that you post currently as posted the argument to \caption is \begin Jun 14, 2018 at 6:53
  • 2
    Your document is not relevant as no one can see it. Do as you are asking others to do, copy the above in to a new file and run it. Jun 14, 2018 at 6:55
  • 2
    note that it is a bad idea (but unrelated to this question) to redefine m and b as they are the built in column types from the array package. with your edit you changed m to mid which can not work at all, the column types have to be a single token. Jun 14, 2018 at 6:56
  • 1
    overflow happens since your multirow text has more lines as other cells in spanned row.
    – Zarko
    Jun 14, 2018 at 7:50

1 Answer 1

1

Some comments and observations:

  • The X column type of the tabularx package should be used only if line breaking is needed. Since the final 6 columns would seem to require no line-breaking, I suggest you use X (or a modified version, see the code below) for the first 2 columns only. Note that the sum of the (relative) widths of the X columns must equal the number of columns of type X. In the code below, 0.6+1.4=2=number of columns of type X.

  • I would also do away with the \multirow wrappers and, instead, concentrate on setting the width of the second column large enough so that the cell contents occupy no more than 3 lines. Why 3? Because there are 3 rows to the right of the cell.

  • Do give your table a more open "look" by omitting all vertical lines and using fewer, but well-spaced, horizontal lines. Adding whitespace between row tends to be every bit as effective as drawing a line, while being much less visually disruptive.

enter image description here

\documentclass[a4paper,12pt]{scrreprt}
\usepackage[ngerman]{babel}
\usepackage{tabularx,ragged2e,booktabs,amsmath}
\newcolumntype{L}[1]{>{\RaggedRight\arraybackslash\hspace{0pt}%
                     \hsize=#1\hsize}X}
\newcolumntype{P}{>{\RaggedRight\hspace{0pt}}p{\hsize}}
\newcommand{\mycell}[1]{\smash[b]{%
    \begin{tabular}[t]{@{}P@{}} #1 \end{tabular}}}

\begin{document}
\begin{table}
\caption{caption} \label{tab:meinetabelle}
\begin{tabularx}{\textwidth}{@{} L{0.6} L{1.4} *{6}{c} @{}}
\toprule
A & & B & C & D & E & F & G \\ 
\midrule
A & B & & C & 373 & 361 & 679 & 676 \\
  & A & & B & 321 & 321 & 660 & 660 \\ 
  & A & & B & 210 & 210 & 245 & 245 \\
\addlinespace
\mycell{Startparameter}
& \mycell{Zeit zw. Anforderung und techn. Mindestlast bei Anfahrt}
& Kaltstart &min &500 &500 &515 &515 \\
       & &A &min &470 &470 &433 &433 \\
       & &B &min &470 &470 &380 &380 \\
\addlinespace
& \mycell{Zeit zw. Synchronisation und techn.\ Mindestlast}
& Kaltstart &min &500 &500 &515 &515 \\
      & & A &min &470 &470 &433 &433 \\
      & & B &min &470 &470 &380 &380 \\ 
\addlinespace
& \mycell{Duchschnittsgradient zw. Synchronisation und technischer Mindestlast}
& Kaltstart &MW/min &2,6 &2,6 &4,5  &4,5  \\
      & & A &MW/min &3,5 &3,5 &10,7 &10,7 \\ 
      & & B &MW/min &3,5 &3,5 &12,3 &12,3 \\
\bottomrule
\end{tabularx}
\end{table}

\end{document} 
3
  • 1
    Thank you very much, it looks much cleaner than before. Works perfectly! Jun 14, 2018 at 7:55
  • Incidentally, as as a matter of consistency in writing (not LaTeX coding!), I'd say that if you're going to abbreviate the word "technischer" in two cells, you should apply the abbreviation to all three cells.
    – Mico
    Jun 14, 2018 at 7:55
  • 1
    Oh, I didn't see that! Thanks again! Jun 14, 2018 at 7:57

You must log in to answer this question.

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