2

This question already has an answer here:

The problem is that there is not enough space between the rules on top of each cell and its content.

The use of \arraystretch doesn't work in my example because I don't put my tabularx inside a tabular or table environment.

I am not sure if this is something about my use of \parbox or \mutlirow. That is why I keept it in my MWE here.

\documentclass{scrartcl}
\usepackage{xltxtra}
\usepackage{polyglossia}
\setdefaultlanguage[spelling=new]{german}

\usepackage{multirow}
\usepackage{tabularx}
\usepackage{calc}
\newlength{\mrwidth}

\begin{document}
\newcommand{\mytext}{And then it happened… a door opened to a world…
    rushing through the phone line like heroin through an addict's veins, an
    electronic pulse is sent out, a refuge from the day-to-day incompetencies is
    sought… a board is found.}

\setlength{\mrwidth}{0.2\textwidth-2\tabcolsep}
\renewcommand\arraystretch{1.1}  % <-- doesn't work here

\begin{tabularx}{\textwidth}{|X|X|X|X|X|}
    \hline
    \multirow{2}*{\parbox{\mrwidth}{\mytext}}
        &b&c&d&e\\\cline{2-5}
    &\parbox{\mrwidth}{\mytext}
        &c&d&e\\\hline
\end{tabularx}
\end{document}

enter image description here

marked as duplicate by Werner, egreg, user13907, Stefan Pinnow, Jesse Aug 28 '16 at 18:19

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • The use of \arraystretch doesn't work in my example because I don't put my tabularx inside a tabular or table environment. ??? \arraystretch works with tabularx in the same way as it works with other tabular variants` it does not need to be in a surrounding table or tabular – David Carlisle Aug 28 '16 at 15:19
  • How important is it to you that all five columns have exactly the same width? Please advise. – Mico Aug 28 '16 at 18:16
  • @buhtz -- What does "a solution against that rule" mean? Please clarify. – Mico Aug 28 '16 at 19:49
  • @Mico It is important. But I am interested in your solution. – buhtz Aug 28 '16 at 19:52
  • As I don't know what "a solution against that rule" might mean, I'm not in a position to provide an answer. (That, and the fact the posting is currently closed a duplicate, meaning that no new answers can be posted...) – Mico Aug 28 '16 at 19:56
1

The \rewnewcommand\araystretch{1.1} is not cure for all cases ... your table is quit unusual, so it doesn't help in placing of text in multirow cells. In your case you need another aproach, for example use of gapedcells from package makecell:

\documentclass{scrartcl}
\usepackage{xltxtra}
\usepackage{polyglossia}
\setdefaultlanguage[spelling=new]{german}

\usepackage{makecell}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{calc}

\begin{document}
\newcommand{\mytext}{And then it happened ... a door opened to a world ...
    rushing through the phone line like heroin through an addict's veins, an
    electronic pulse is sent out, a refuge from the day-to-day incompetencies 
    is a board is found.}

\setcellgapes{5pt}
\makegapedcells
\begin{tabularx}{\textwidth}{|X|X|X|X|X|}
    \hline
    \multirow{10}*{\parbox{\linewidth}{\mytext}}
        &b&c&d&e\\\cline{2-5}
    &\mytext
        &c&d&e\\\hline
\end{tabularx}
\end{document}

enter image description here

Note: The \arraystretch work as name implied, in any array environment, from array, tabular to even tabu (most of them are based on array). Regarding columns width in your table: if it is not necessary that all to have the same width, you can change it, for example with >{\setlength\hsize{0.5\hsize}}X (to make it narrower) or even in case, that in columns are cells with only one line text use l column type. With this you can increase width of other X columns and obtain nicer text formatting in it.

Already now you can obtain slightly better text formatting, if you reduce font size and its shape:

{\sffamily\small
\begin{tabularx}{\textwidth}{|X|X|X|X|X|}
...
\end{tabularx}
}

enter image description here

Beside this is worth consider package ragged2e and its macro \RaggedRight. With it text is not justified anymore, but hyphenation still works. With it you obtain the following result:

enter image description here

(considered \sffamily\small fonts). Changes in above MWE are: added \usepackage{ragged2e} in preamble and in table:

\begin{tabularx}{\textwidth}{|X|X|X|X|X|}
    \hline
    \multirow{10}*{\parbox{\mrwidth}{\RaggedRight\mytext}}
        &b&c&d&e\\\cline{2-5}
    &\RaggedRight\mytext
        &c&d&e\\\hline
\end{tabularx}

Addendum: In all efforts to make good answers for you I forgot an very basic mutirow futures: defining it width with linewidth. This introduce p{\linewidth} type of cell, where the text is automatically broken in multi line text. So, the parbox seems to be not necessary (on this remind me Bernard answer, where this is used), however the hyphenation seems to be different. Difference is observable, if you futher decrease font size to footnotesize:

enter image description here

In above picture the first column is without use of \parbox. With its ˛use, the text shape in this column is the same as in the secon.

  • I see we had the same basic idea, with some differing details. Did you try with cellspace? – Bernard Aug 28 '16 at 14:58
  • No, I'm not familiar with it yet. I know, that in some circumstances it make less troubles as makecell. I need to read its manual again. In the first look i obtain (probably wrong) impression, that it is complicated ... – Zarko Aug 28 '16 at 15:06
1

With the makecell package and its\setcellgapes command, it's easy, and you can have a simpler code. No \parbox with width computation needed.

\documentclass{scrartcl}
\usepackage{xltxtra}
\usepackage{polyglossia}
\setdefaultlanguage[spelling=new]{german}
\usepackage{geometry}
\geometry{showframe, a4paper}
\usepackage{ragged2e}
\usepackage{multirow}
\usepackage{tabularx, makecell}
\setcellgapes{4pt}

\begin{document}
\newcommand{\mytext}{And then it happened… a door opened to a world…
    rushing through the phone line like heroin through an addict's veins, an
    electronic pulse is sent out, a refuge from the day-to-day incompetencies is
    sought… a board is found.}

{\setlength\tabcolsep{4pt}
\makegapedcells
\noindent\begin{tabularx}{\linewidth}{|*{5}{>{\RaggedRight\arraybackslash}X|}}
    \hline
    \multirow{2}{\linewidth}{\mytext}
        &b&c&d&e\\\cline{2-5}
    & \mytext
        &c&d&e\\\hline
\end{tabularx}}

\end{document}

enter image description here

  • 1
    I forgot on defining multirow width with linewidth. Very elegant and far more simple solution than mine (+1)! – Zarko Aug 28 '16 at 15:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.