0

I want to have a table with cells which have multiple lines and bottom rules.

I've tried

\begin{tabular}{cc}
\renewcommand{\arraystretch}{1.5}

Title & \parbox{18em}{\centering A very very very very very very very very very very very very very very very long title}\\\cmidrule(lr){2-2}
SubTitle & \parbox{18em}{\centering A not that long title}\\\cmidrule(lr){2-2}
\end{tabular}

which seems to work fine. But the second cmidrule is a little bit far away from the text.

My first attempt begins with

\uline\makebox[18em][c]{A very very very very very very very very very very very \\ very very very very long title}

but apparently it doesn't support breaking lines inside the box.

I also tried \parbox with \ul (in the soul package) but error throws.

I think the closest approach is combine \framebox with \parbox but I don't know how to have the bottom rule only.

  • BTW, I also tried make a tcolorbox inside a cell but its nearby cell seems not vertically centered with that cell... – SXKDZ Mar 25 '19 at 1:23
  • What is the reason for using parbox? Wouldn't a p type column be sufficient in order to allow for linebreaks in table cells? – leandriis Mar 25 '19 at 6:04
  • @leandriis I wanna have a bottom rule of a fixed length. p works fine but I cannot have a single bottom rule only. – SXKDZ Mar 25 '19 at 6:35
1

Package fbox provides and optional command to fbox where you decide which sides of surrounding box are drawn.

\documentclass{article}
\usepackage{array}
\usepackage{booktabs}
\usepackage{fbox}

\begin{document}
\begin{tabular}{c>{\centering\arraybackslash}p{18em}}
\renewcommand{\arraystretch}{1.5}
Title & \fbox[b]{\parbox[t]{18em}{A very very very very very very very very very very very very very very very long title}}\\
SubTitle & \fbox[b]{A not that long title}\\
\end{tabular}

\end{document}

enter image description here

|improve this answer|||||
1

I'm not sure this is what you want to achieve, but \cmidrule can be shortened of a desired amount, see: How to make a \cline or \cmidrule narrower?

\documentclass{article}
\usepackage{array}
\usepackage{booktabs}

\begin{document}
\begin{tabular}{c>{\centering\arraybackslash}p{18em}}
\renewcommand{\arraystretch}{1.5}
Title & A very very very very very very very very very very very very very very very long title\\\cmidrule(lr){2-2}
SubTitle & A not that long title\\\cmidrule(l{4.5em}r{4.5em}){2-2}
\end{tabular}

\end{document}

enter image description here

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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