# line break within table column

I have looked up many of the previous posts on this....but of no avail.....I need a solution to break a line within a table column, without a break appearing at the table edge of the second row....my table has only two rows....is there a way to do this?

for instance

\begin{table}[H]

\begin{center}

\begin{tabular}{| c | p{3cm} |}

\hline

\textbf{Equation} & \textbf{Description} \\

\hline

eq1\\ eq2 & "some text" \\\hline

\hline


Now because of the \\ between eq1 and eq2, a break occurs in the line bordering the table after "some text". I need a workaround to avoid the table breaking at the end of the second row. The method eq1\\\ eq2 does shift eq2 to a new line within the same column, which is what I want, but without the side effect of the right border to the second row breaking at the same point. In other words, the splitting into two lines should be confined within the same column, without impacting the row.

Appreciate your thoughts.

## 2 Answers

You can use a tabular inside a tabular

\documentclass{article}
\newcommand{\mysplit}[1]{%
\begin{tabular}[t]{@{}c@{}}   %% remove [t] if you need vertical centered things.
#1
\end{tabular}
}
\begin{document}
\begin{table}[htb]
\centering
\begin{tabular}{| c | p{3cm} |}
\hline
\textbf{Equation} & \textbf{Description} \\
\hline
\mysplit{eq1\\ eq2} & some text'' \\\hline
\hline
\end{tabular}
\end{table}
\end{document}


Note that I have changed

"some text" to some text''

[H] to [htb]

as they are the recommended ways.

Further it is better to get rid of vertical lines and use booktabs for drawing rules.

\documentclass{article}
\usepackage{booktabs}
\newcommand{\mysplit}[1]{%
\begin{tabular}{@{}c@{}}   %% removed [t]
#1
\end{tabular}
}
\begin{document}
\begin{table}[htb]
\centering
\begin{tabular}{ c  p{3cm} }
\toprule
\textbf{Equation} & \textbf{Description} \\
\midrule
\mysplit{eq1\\ eq2} & some text'' \\\bottomrule
\end{tabular}
\end{table}
\end{document}


For details a some tutorial please the booktabs manual which you can get by running texdoc booktabs from command prompt or in the texdoc help menu of your tex editor.

You can do that most easily with the makecell package, which allows for linebreaks and a common formatting in cells, with the \thead and \makecell commands:

\documentclass{article}
\usepackage{makecell, booktabs, mathtools}
\setcellgapes{4pt}
\makegapedcells
\begin{document}

\begin{table}
\centering
\begin{tabular}{c p{3cm}}
\toprule
\textbf{Equation} & \textbf{Description} \\
\midrule
\makecell{ eq1\\ eq2 } & "some text" \\
\bottomrule
\end{tabular}
\end{table}

\end{document}