I have a table with some multirow
cells. Sometimes the cell content is wider than the cell, the it has to make a breakline. Reading a little, I founded that specifying the multirow
width, the text will automatically break, however, after the linebreak, the text stay outside of the cell. How can I solve it?
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{rotating}
\usepackage{booktabs}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{array}
\begin{document}
\begin{table}
\centering
\begin{tabular}{c*2{>{\centering\arraybackslash}m{2cm}}}
\cmidrule{2-3}
& \textbf{Column 1} & \textbf{Column 2}\\
\midrule
\textbf{Row 1} & \multirow{2}{*}{A longer text for line break} & Text row 1\\
\cmidrule{1-1}\cmidrule{3-3}
\textbf{Row 2} & & Text row 2\\
\midrule
\textbf{Row 3} & Text row 3 & A longer text for line break\\
\midrule
\end{tabular}
\end{table}
%
\begin{table}
\centering
\begin{tabular}{c*2{>{\centering\arraybackslash}m{2cm}}}
\cmidrule{2-3}
& \textbf{Column 1} & \textbf{Column 2}\\
\midrule
\textbf{Row 1} & \multirow{2}{2cm}{\centering A longer text for line break} & Text row 1\\
\cmidrule{1-1}\cmidrule{3-3}
\textbf{Row 2} & & Text row 2\\
\midrule
\textbf{Row 3} & Text row 3 & A longer text for line break\\
\midrule
\end{tabular}
\end{table}
\end{document}