TeX - LaTeX Asked by asdfsdfwewrwe on July 5, 2021
I have a table:
begin{tabularx}{textwidth}{|>{color{white}}>{columncolor[gray]{0}}l X | X | X | X |}
cline{1-2}
Proposal Code &
hline
Short Description & multicolumn{4}{X}{}
hline
multirow{2}{*}{Spread} & & & &
cline{2-5}
& & & &
hline
end{tabularx}
This creates a table with four rows:
The first row works fine. The second row doesn’t have a right border despite the second and fifth columns having borders elsewhere. What gives?
There are two main issues with your code:
The four narrow columns are really of type X|
, not X
; note that each of these columns is associated with a vertical rule to the right. This explains why
multicolumn{4}{X}{}
fails to draw a vertical line at its right-hand edge. What's needed is
However, this still isn't quite right, as any text in this "wide" column will occupy only the width of the first of the four columns. What's really needed, then, is
multicolumn{4}{>{hsize=4hsize}X|}{}
That way, if and when you start providing text material for the combined cell, it'll occupy all four of the underlying narrow columns.
There's a further, relatively minor point: Instead of placing
multirow{2}{*}{Spread}
in the third row, you should place
multirow{-2}{*}{Spread}
in the fourth row.
I'd also replace >{color{white}}>{columncolor[gray]{0}}
with >{color{white}columncolor[gray]{0}}
.
The result:
documentclass{article}
usepackage{tabularx,multirow}
usepackage[table]{xcolor}
begin{document}
noindent % <-- important
begin{tabularx}{textwidth}{ | >{color{white}columncolor[gray]{0}}l *{4}{X|} }
cline{1-2}
Proposal Code &
hline
Short Description & multicolumn{4}{>{hsize=4hsize}X|}{bla bla bla bla bla bla bla}
hline
& & & &
hline
multirow{-2}{*}{Spread} & & & &
hline
end{tabularx}
end{document}
Correct answer by Mico on July 5, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP