TransWikia.com

Table with multirow & multicolumn, spacing problems

TeX - LaTeX Asked on March 24, 2021

The following table is aesthetically sub-optiomal.

enter image description here

The vertical spacing between paragraph rows is bigger than the one between table rows, e.g. second and third lines.

The horizontal size is hard-coded (two different lengths, i.e. column 2+3, and 3 only.

documentclass{article}
usepackage{multirow,bigdelim}

begin{document}

begin{table}
begin{minipage}{textwidth}
renewcommand{arraystretch}{1.1}
begin{tabular}{lcp{0.75textwidth}}
texttt{aaaaaaaaa} & multicolumn{2}{l}{parbox[t]{0.8textwidth}{Blah blah blah
  blah blah blah blah blah blah blah blah blah blah blah blah.}}
texttt{bbbbbbb} & multicolumn{2}{l}{parbox[t]{0.8textwidth}{Blah blah blah
  blah blah blah blah blah blah.}}
texttt{ccccccccccc} & multicolumn{2}{l}{parbox[t]{0.8textwidth}{Blah blah
  blah blah blah blah blah blah blah blah blah blah blah.}}
texttt{ddddddddd} & multicolumn{2}{l}{parbox[t]{0.8textwidth}{Blah blah blah
  blah blah blah blah blah blah blah blah blah.}}
texttt{eeeeeeeee} & rdelim}{2}{0pt} & multirow{2}{*}{%
  parbox[t]{0.75textwidth}{Blah blah blah blah blah blah blah blah blah blah
  blah blah.}}
texttt{ffffffff} & & 
end{tabular}
end{minipage}
end{table}

end{document}

Is there a better way to do this? How do I solve the problems mentioned above?

(There are multiple other questions about multirow and multicolumn but I did not find one that seemed identical.)

3 Answers

enter image description here

documentclass{article}
usepackage{array}
usepackage{bigdelim}

begin{document}

begin{table}
renewcommand{arraystretch}{1.1}
begin{tabular}{>{ttfamily}lp{0.75textwidth}}
aaaaaaaaa   & Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah.
bbbbbbb     & Blah blah blah blah blah blah blah blah blah.
ccccccccccc & Blah blah   blah blah blah blah blah blah blah blah blah blah blah.
ddddddddd   & Blah blah blah blah blah blah blah blah blah blah blah blah.
eeeeeeeee   &rdelim}{2}{0.75textwidth}[parbox{dimexpr 0.75textwidth-9pt}{Blah blah blah blah blah blah blah blah blah blah
  blah blah.}] 
ffffffff    &  
end{tabular}
end{table}

end{document}

Here's a slightly more automatic aolution that almost perfectly fits into the textwidth, but still requires you to explicitly set the width of the first column according to its widest entry:

documentclass{article}
usepackage{array}
usepackage{bigdelim}

usepackage{calc}
newlength{myfirstcol}
newlength{mysecondcol}
newlength{mythirdcol}
setlength{myfirstcol}{widthof{texttt{ccccccccccc}}}
setlength{mysecondcol}{textwidth-4tabcolsep-myfirstcol}
setlength{mythirdcol}{mysecondcol-widthof{$Bigg}$}}
begin{document}

begin{table}
renewcommand{arraystretch}{1.1}
begin{tabular}{>{ttfamily}wl{myfirstcol}p{mysecondcol}}
aaaaaaaaa   & Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah.
bbbbbbb     & Blah blah blah blah blah blah blah blah blah.
ccccccccccc & Blah blah   blah blah blah blah blah blah blah blah blah blah blah.
ddddddddd   & Blah blah blah blah blah blah blah blah blah blah blah blah.
eeeeeeeee   &rdelim}{2}{mysecondcol}[parbox{mythirdcol}{Blah blah blah blah blah blah blah blah blah blah
  blah blah.}] 
ffffffff    &  
end{tabular}
end{table}

end{document}

Correct answer by leandriis on March 24, 2021

A solution (and a simpler code) with tabularx:

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

begin{document}

begin{table}
setlength{extrarowheight}{4pt}
begin{tabularx}{linewidth}{l@{,}c@{}X@{}}
texttt{aaaaaaaaa} & & Blah blah blah
  blah blah blah blah blah blah blah blah blah blah blah blah.
texttt{bbbbbbb} & & Blah blah blah
  blah blah blah blah blah blah. 
texttt{ccccccccccc} & & Blah blah
  blah blah blah blah blah blah blah blah blah blah blah. 
texttt{ddddddddd} & & Blah blah blah
  blah blah blah blah blah blah blah blah blah. 
texttt{eeeeeeeee} & & 
texttt{ffffffff} & llap{rdelim}{-1.6}{*}}enspace& multirow{-1.6}{=}{Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah.} 
end{tabularx}
end{table}

end{document} 

enter image description here

Added: A way to obtain what you want, as to the alignment of the brace:

begin{tabularx}{linewidth}{l@{,}X@{}}
    texttt{aaaaaaaaa} & Blah blah blah
      blah blah blah blah blah blah blah blah blah blah blah blah.
    texttt{bbbbbbb} & Blah blah blah
      blah blah blah blah blah blah. 
    texttt{ccccccccccc} & Blah blah
      blah blah blah blah blah blah blah blah blah blah blah. 
    texttt{ddddddddd} & Blah blah blah
      blah blah blah blah blah blah blah blah blah. 
    texttt{eeeeeeeee} & 
    texttt{ffffffff} & rdelim}{-1.6}{*}[,parbox{0.97hsize}{Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah.}]
    end{tabularx}

enter image description here

Answered by Bernard on March 24, 2021

A solution with the latest version of nicematrix (v. 5.11 2021-02-22). The size of the brace is computed automatically from the contens of the cell (no manual adjustment needed).

documentclass{article}
usepackage{multirow}
usepackage{nicematrix}
usepackage{bigdelim}

begin{document}

begin{table}
renewcommand{arraystretch}{1.1}
begin{NiceTabular}{>{ttfamily}lp{0.75textwidth}}
aaaaaaaaa   & Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah.
bbbbbbb     & Blah blah blah blah blah blah blah blah blah.
ccccccccccc & Blah blah   blah blah blah blah blah blah blah blah blah blah blah.
ddddddddd   & Blah blah blah blah blah blah blah blah blah blah blah blah.
eeeeee      & multirow{2}{=}{advance leftskip by 1 em Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah.} 
ffffffff    &  
CodeAfter SubMatrix{.}{5-1}{6-1}}[right-xshift=2tabcolsep]
end{NiceTabular}
end{table}

end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes).

Output of the above code

Answered by F. Pantigny on March 24, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP