4

I have a table table and the first column is a multirow. The multirow column text exceeds the column with.

\documentclass{article}

\usepackage[dutch]{babel}
\usepackage{ragged2e}
\usepackage{ltablex, multirow, makecell, caption}

\begin{document}

\keepXColumns\setcellgapes{3pt}\makegapedcells
\begin{tabularx}{\linewidth}{|p{25mm}|*{3}{>{\RaggedRight\arraybackslash}X|}}
  \caption{My caption}
  \label{my-label} \\

  \hline
 Onderwerp & Persoonlijk niveau & Professioneel niveau & Samenlevingsniveau \\ \hline


  \multirow{4}{*}{Perspectief: Wat is het hogere doel} 
    & Wat is jouw hoge doel in het leven?  & Wat is jouw hoge doel in je beroep? &  Wat is jouw hoge doel in de samenleving? \\ \cline{2-4}
    & & & x \\ \cline{2-4}
  \hline

\end{tabularx}

\end{document}

enter image description here

How can I make the text wrap and go to next line when the line is longer then the column width like the other columns?

4
  • 1
    Firstly, start by adding babel with appropriate language (Dutch?), tight now it is probably English, and that word can probably not be hyphenated correctly under the default English patterns, plus the trick David mentioned which I keep forgetting
    – daleif
    Oct 1, 2017 at 12:41
  • I have edited the code with the correct babel language.
    – oscarteg
    Oct 1, 2017 at 12:55
  • @barbarabeeton thank you for the reference. I'm still learning and love the learn more about tex
    – oscarteg
    Oct 1, 2017 at 14:49

1 Answer 1

8

TeX does not hyphenate the first word of a paragraph, so add a 0pt space before the word. You also need to specify a language, hyphenating this text using the rules for English does not make a good outcome.

\documentclass{article}

\usepackage{ragged2e}
\usepackage{ltablex, multirow, makecell, caption}

\begin{document}

\keepXColumns\setcellgapes{3pt}\makegapedcells
\begin{tabularx}{\linewidth}{|>{\hspace{0pt}}p{25mm}|*{3}{>{\RaggedRight\arraybackslash\hspace{0pt}}X|}}
  \caption{My caption}
  \label{my-label} \\

  \hline
 Onderwerp & Persoonlijk niveau & Professioneel niveau & Samenlevingsniveau \\ \hline


  \multirow{4}{=}{Perspectief: Wat is het hogere doel} 
    & Wat is jouw hoge doel in het leven?  & Wat is jouw hoge doel in je beroep? &  Wat is jouw hoge doel in de samenleving? \\ \cline{2-4}
    & & & x \\ \cline{2-4}
  \hline

\end{tabularx}

\end{document}
2
  • Thank you for your answer. I have edited the code with the dutch babel. So I need to add a 0pt space in the multirow so it wrappes the entire section if its to large for the column? I'm rather new at this.
    – oscarteg
    Oct 1, 2017 at 12:59
  • @oscarteg you only need the space to allow hyphenation of the first word, for the multirow use = not * (I changed my answer) Oct 1, 2017 at 13:13

You must log in to answer this question.

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