Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An alternative to write multirow in latex's tabular?

In latex, I know we can use the multirow command like the following,

\begin{table}[!h]
    \centering
    \begin{tabular}{|c|l|}
        \hline
        \multirow{2}{*}{A}
        & I want to place this sentence in multiple lines, \\
        & but don't want to control the linebreak myself \\
        \hline
    \end{tabular}
\end{table}

enter image description here

I think it is so stupid to control the linebreak myself.

Any other alternative that fits the text width to line width?

like image 715
user9985127 Avatar asked Nov 25 '25 19:11

user9985127


1 Answers

\documentclass{article}

\usepackage{tabularx}
\renewcommand\tabularxcolumn[1]{m{#1}}

\begin{document}

\begin{table}[htbp]
    \centering
    \begin{tabularx}{\linewidth}{|c|X|}
        \hline
        A
        & I want to place this sentence in multiple lines, but don't want to control the linebreak myself \\
        \hline
    \end{tabularx}
\end{table}

\end{document}

enter image description here

like image 53
samcarter_is_at_topanswers.xyz Avatar answered Nov 28 '25 05:11

samcarter_is_at_topanswers.xyz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!