An alternative to write multirow in latex's tabular?

1.1k views Asked by At

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?

1

There are 1 answers

0
samcarter_is_at_topanswers.xyz On BEST ANSWER
\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