# tabularx: Cell With Manual Line Breaks | Problem With Vertical Line [duplicate]

When I have a manual line break in a cell of a tabularx table, then the vertical line goes missing.

\documentclass{article}

\usepackage{tabularx}

\usepackage[sfdefault]{cabin}

% https://tex.stackexchange.com/questions/89166
\newcolumntype{Y}{>{\centering\arraybackslash}X}

\begin{document}

\begin{tabularx}{\textwidth}{lc|l|Y|Y|Y|Y}
\hline
% Row
Text & & & & & & \\ \hline
% Row
Text\\ Text & & & & & & \\ \hline
\end{tabularx}

\end{document}


## marked as duplicate by David Carlisle, Mico, Stefan Pinnow, Mensch, ebosiMay 1 '17 at 20:25

• problem is in this line: Text\\ Text & & & & & & \\ \hline if the firs text is own row (in l column type only this is sensible, since it is not designe for multline contents)than it should follows ampersands for each empty cell. – Zarko May 1 '17 at 19:41
• @Zarko Thanks. So the \\ isn't "allowed" with in a cell? – Dr. Manuel Kuehner May 1 '17 at 19:45
• @Dr.ManuelKuehner Many column specific stuff does require the column to be existent. It's the same with e.g. \rowcolor, which also only colors the cells which are existent. If you end a line in a tabular the remaining cells are non existent to those formattings. – Skillmon May 1 '17 at 19:50
• Not sure what you mean by the comment above. \\  ends the row so that row only has one cell. The vertical lines are all the right hand content of a cell (except the first cell which has left and right rules) so if you omit the cell the line goes, just as if you omit it with \multicolumn – David Carlisle May 1 '17 at 19:53
• @Dr.ManuelKuehner, directly in cell no, as you see from other comments and answer. – Zarko May 1 '17 at 19:59

If you want line breaks in one of the l, c, r column types, you have to load makecell package and use its eponymous command. Otherwise, \\ is taken as a row change. With this code, it's fine:

\documentclass{article}

\usepackage{tabularx, makecell}

\usepackage{fontawesome}

\usepackage[sfdefault]{cabin}

% https://tex.stackexchange.com/questions/89166
\newcolumntype{Y}{>{\centering\arraybackslash}X}

\begin{document}

\begin{tabularx}{\textwidth}{lc|l|Y|Y|Y|Y}
\hline
% Row
Text & & & & & & \\ \hline
% Row
\makecell[l]{Text\\ Text} & & & & & & \\ \hline
\end{tabularx}

\end{document}


• Another possibility is the use of \pbox. – Skillmon May 1 '17 at 19:55
• Thanks. The makecell package seems to be very useful. Some of my last table-related questions were solved by using it. – Dr. Manuel Kuehner May 1 '17 at 19:55
• @Skillmon Thanks. I'll upvote if you provide an answer (probably not today...going to bed). – Dr. Manuel Kuehner May 1 '17 at 19:56

You can always put boxes in tables in which \\ doesn't end the table row. One handy command is \pbox as it doesn't use more space than necessary but has a maximum width. Unfortunately, the vertical spacing doesn't fit with just \pbox. Here is an example:

\documentclass{article}

\usepackage{tabularx}
\usepackage{pbox}

% https://tex.stackexchange.com/questions/89166
\newcolumntype{Y}{>{\centering\arraybackslash}X}

\begin{document}

\begin{tabularx}{\textwidth}{lc|l|Y|Y|Y|Y}
\hline
% Row
Text & & & & & & \\ \hline
% Row
\pbox{\textwidth}{Text\\ Text} & & & & & & \\ \hline
\end{tabularx}

\end{document}


One can clearly see, that the vertical spacing isn't right in the above image.