0

The following situation gives me a lot of headache: 1) I would like to use \parbox to have also block text in the multirow areas. With the code below this doens't work. I tried to combine \parbox and \multirow in many ways but I got some errors... May someone know an elegant/easy solution for this problem? 2) I would like prefer another solution to writing [36pt] by guessing it!

Here is the relevant code:

    \begin{table}[!htbp]  
    \renewcommand{\arraystretch}{1.5}   
    \begin{tabular}{ | p{0.04\textwidth} | p{0.36\textwidth} | p{0.22\textwidth} | p{0.26\textwidth} |}  
      \hline   
      \textbf{Nr.} & \textbf{Metrik}  & \textbf{Bewertungsskala}  & \textbf{Wertebereich} \\                                      
      \hline
      1 & Ist das Verfahren im Bezug auf neu entwickelten Code bzw. Features anwendbar? & \multirow[t]{2}{*}{Likert Skala} & \multirow[t]{2}{0.26\textwidth}{{1: Stimme völlig zu\newline 2: Stimme zu\newline 3: Stimme weder zu noch nicht zu\newline 4: Stimme nicht zu\newline 5: Stimme überhaupt nicht zu}} \\ [36pt] \cline{1-2}
      2 & Ist das Verfahren im Bezug auf Fehlerkorrekturen anwendbar? &  &  \\ \hline
    \end{tabular}
    \caption{Metriken der Kategorie Anwendbarkeit mit Bewertungsskala und dem zulässigem Wertebereich.}
    \label{tab:Anwendbarkeit}
    \end{table}

Thanks in advance!

enter image description here

2 Answers 2

0

Just \parbox{\hsize}{material...} inside \multirow works for me. Does this solve what you are looking for?

In the other hand, the \tabularx environment display tables that automatically fill a given width. Following the package documentation, you can set the row widths in a relative way as it is showed in the code below:

\documentclass{article}
\usepackage{multirow, tabularx}

\begin{document}

\begin{table}[!htbp]  
    \renewcommand{\arraystretch}{1.5}   
\begin{tabularx}{\textwidth}{|>{\hsize=0.05\hsize}X|>{\hsize=0.35\hsize}X|>{\hsize=0.3\hsize}X| >{\hsize=0.3\hsize}X|}
      \hline   
      \textbf{Nr.} & \textbf{Metrik}  & \textbf{Bewertungsskala}  & \textbf{Wertebereich} \\                                      
      \hline
      1 & Ist das Verfahren im Bezug auf neu entwickelten Code bzw. Features anwendbar? &
    \multirow[t]{2}{*}{Likert Skala} &
    \multirow[t]{2}{0.26\textwidth}{% <------ % symbol here
       \parbox[t]{\hsize}{% <------ % symbol here
          1: Stimme völlig zu\newline 2: Stimme zu\newline 3: Stimme weder zu noch nicht zu\newline 4: Stimme nicht zu\newline 5: Stimme überhaupt nicht zu
          }
          }\\ \cline{1-2}
      2 & Ist das Verfahren im Bezug auf Fehlerkorrekturen anwendbar? &  &  \\ \hline
    \end{tabularx}
    \caption{Metriken der Kategorie Anwendbarkeit mit Bewertungsskala und dem zulässigem Wertebereich.}
    \label{tab:Anwendbarkeit}
    \end{table}

\end{document}

note that the relative width factors in \tabularx must sum 1.

enter image description here

5
  • Thank you for your answer! I have copied your suggestion! The first problem ist solved now. The second not. The problem is, that the whole block was shifted vertically down about - let me guess - seems to be exactly one line! So first line is empty, second start with "1: Stimme völlig zu". Do you have any idea why this is happend? Thank you in advice!
    – user216725
    May 27, 2020 at 19:47
  • Sorry, @user216725. I made a small mistake: when you split a line of code in two, spurious whitespace (or even lines like in this case) will appear. This happens because of the TeX syntax itself. The correct syntax requires adding a % comment symbol to the end of the broken line. Please look at the updated answer.
    – e_moro
    May 27, 2020 at 21:09
  • Thank you very much for your answer @e_moro! Seems to work! Problem 1 and 2 is solved. Only to one thing I had a question: In the last row, at the text "3: Stimme weder [...]" After the symbol ":" the Distance to the "S" seems to be 2 spaces instead of one. I think that's maybe because of the parbox? On the other hand the word "zu" in the sentence is perfect aligned to right end of the row, so good!
    – user216725
    May 29, 2020 at 11:11
  • This is because, by default, a LaTeX text is fully-justified. The third line uses the entire width of the line, so the white space is distributed between the words. For this reason, the space between "3:" and "Stimme" is greater than the standard. You can declare \raggedright at the beginning of the \parbox content to force left vertical alignment. If you don't like left alignment, you can use the enumerate environment, but it will need a little tuning (not difficult) using the enumiten package.
    – e_moro
    May 29, 2020 at 20:52
  • Thank you for the quick answer! So the enumerate enviroment seems to be a possible right way for my solution. I would appreciate it, if you can give me some hints how to handle it, Thank you! The rest is totally fine!
    – user216725
    May 30, 2020 at 5:44
0

Just adding a \medskip at the end of the 2nd cell in the last row, and using the correct number of rows in \multirow solves your problem. I also improved your table with a smaller \tabcolsep and using tabularx:

\documentclass{article}
\usepackage[german]{babel} 
\usepackage{multirow, tabularx}

\begin{document}

\begin{table}[!htbp]
\renewcommand{\arraystretch}{1.5}
\setlength{\tabcolsep}{3pt}
\begin{tabularx}{\linewidth}{ | l |>{\hsize=1.26\hsize}X|>{\hsize=0.82\hsize}X| >{\hsize=0.92\hsize}X|}
  \hline
  \textbf{Nr.} & \textbf{Metrik} & \textbf{Bewertungsskala} & \textbf{Wertebereich} \\
  \hline
  1 & Ist das Verfahren im Bezug auf neu entwickelten Code bzw. Features anwendbar? & \multirow[t]{10}{*}{Likert Skala} & \multirow[t]{2}{=}{{1: Stimme völlig zu\\ 2: Stimme zu\\ 3: Stimme weder zu noch nicht zu\\ 4: Stimme nicht zu\\5: Stimme \rlap{überhaupt}\\ nicht zu}} \\ %[36pt]
   \cline{1-2}
  2 & Ist das Verfahren im Bezug auf Fehlerkorrekturen anwendbar? \medskip & & \\ \hline
\end{tabularx}
\caption{Metriken der Kategorie Anwendbarkeit mit Bewertungsskala und dem zulässigem Wertebereich.}
\label{tab:Anwendbarkeit}
\end{table}

\end{document} 

enter image description here

2
  • Thank you for your answer! The first problem doens't seems to be solved, I don't know why, I can only guess! Second one: Now the last to words: "nicht zu" are now above the last horizontal line and outside the table. Have you an idea why this is happend? A Third one is now happend: The vertical distance from the five lines to the corresponding text is now smaller then before! The horizontal one is still correct, that's fine! Thank you!
    – user216725
    May 27, 2020 at 19:57
  • For the first problem: I don't see how it's not solved – you don't need a \parbox, as I used the =` key for \multirow, which means it will have the width of the current column (valid for p{some length} columns). Second problem: does it happen with this very code? Third problem: ?? Only vetical lines are five, so how can they have a vertical distance to something? Unless you meant the horizontal distance?
    – Bernard
    May 27, 2020 at 20:12

You must log in to answer this question.

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