# How to get automatic line-breaks using tabularx and makecell?♀

I'm using the tabularx and makecell packages for the aesthetics of my tables. I used the X column type for columns with long texts and \makecell{...} for line-breaks into the cells. But when I try to use both together, the effect of the X columns doesn't work.

In the MWE I'd like that the long text um the 3rd line of the 1st row and last column breaks automatically. Any help?

\documentclass{article}
\usepackage{tabularx}
\usepackage{blindtext}
\usepackage{booktabs}
\usepackage{makecell}

\begin{document}

\begin{table}[h]
\footnotesize
\centering
\caption{Table's caption}%
\label{tab:Example}%
\begin{tabularx}{\linewidth}{lcX}%
\toprule
\midrule
Row 1           & 1                 & \makecell[lt]{Line 1\\Line 2\\\blindtext} \\
Row 2           & 2                 & \makecell[lt]{Line 1\\Line 2\\Line 3}     \\
\bottomrule
\end{tabularx}
\end{table}

\end{document}


• X columns allow line breaks anyway, (\newline or a blank line for a new paragraph) why \makecell ? \makecell is for cases like table headings where you only want forced line breaks and there is no automatic breaking) – David Carlisle Feb 20 at 15:27
• @DavidCarlisle Sorry. I didn't know that I could do this – Daniel Valencia C. Feb 20 at 15:31
• X columns are just p columns so you can do anything in an X column that you can do in a standard tabular p column. – David Carlisle Feb 20 at 15:36

You could as well use \makecell[Xt]{...} (though, like @DavidCarlisle said, it doesn't really make sense):

\documentclass{article}
\usepackage{tabularx}
\usepackage{blindtext}
\usepackage{booktabs}
\usepackage{makecell}

\begin{document}

\begin{table}
\footnotesize
\centering
\caption{Table's caption}%
\label{tab:Example}%
\begin{tabularx}{\linewidth}{lcX}%
\toprule
\midrule
Row 1           & 1                 & \makecell[Xt]{Line 1\\Line 2\\\blindtext} \\
Row 2           & 2                 & \makecell[lt]{Line 1\\Line 2\\Line 3}     \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}


\documentclass{article}
\usepackage{tabularx}
\usepackage{blindtext}
\usepackage{booktabs}
\usepackage{makecell}

\begin{document}

\begin{table}[htp] % not [h]
\footnotesize
\centering
\caption{Table's caption}%
\label{tab:Example}%
\begin{tabularx}{\linewidth}{lcX}%
\toprule
\midrule
Row 1           & 1                 &
Line 1

Line 2

\blindtext
\\
Row 2           & 2                 &
Line 1

Line 2

Line 3
\\
\bottomrule
\end{tabularx}
\end{table}

\end{document}


As @DavidCarlisle says, I used \newline to solve it

\documentclass{article}
\usepackage{tabularx}
\usepackage{blindtext}
\usepackage{booktabs}
\usepackage{makecell}

\begin{document}

\begin{table}[h]
\footnotesize
\centering
\caption{Table's caption}%
\label{tab:Example}%
\begin{tabularx}{\linewidth}{lcX}%
\toprule

• why use \makecell in row 2? – David Carlisle Feb 20 at 15:35