Graphics, Figures & TablesLine Break in Table Cells spanning multiple Rows

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
fboehlandt
Posts: 12
Joined: Mon Apr 15, 2013 6:28 pm

Line Break in Table Cells spanning multiple Rows

Post by fboehlandt »

Hello everyone,

I have a problem concerning line breaks when using multirow. The 'natural' width * ignores the table definitions for column width. The text overlaps the adjacent column. A dummy solution is to enter a column width manually based on what looks good after compilation. This is clearly not ideal. Is there no way to invoke the column width specification from within multirow? I know this was posted before but I could not find a satisfactory answer.

P.S.: You may ignore the \url parts. The line breaks are working fine

Code: Select all

\documentclass{article}
\usepackage[utf8]{inputenc}

% visualize page dimensions:
\usepackage{showframe}
\usepackage{booktabs, multicol, multirow}
\usepackage[hyphens]{url}

% table packages
\usepackage{array,booktabs,tabularx}

\begin{document}
  \newcolumntype{R}{>{\raggedleft\arraybackslash}X}%

  \begin{table}
    \caption{Frequency distribution of returns}
    \centering
    \begin{tabularx}{\textwidth}{@{}R*{9}{X}@{}}
      \toprule
      header1 & header2 \\
      \midrule
      \multirow{4}{*}{a very long cell content that will be much wider than the specified column width of .5 table width}  & content2: \\
      & \url{http://www.hedge-fund-analysis.net} \\
      & WML: \\
      & \url{http://www.hedge-fund-analysis.net} \\
      \\
      \bottomrule
    \end{tabularx}
  \end{table}
\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Line Break in Table Cells spanning multiple Rows

Post by localghost »

Wherever line breaks are required, a \parbox (← Link!) with a certain width can be helpful.


Thorsten
Post Reply