# I don't use \centering, but why must I use \arraybackslash in my table?

I don't use \centering or \Centering in my table below.

But I will get errors if I don't insert \arraybackslash.

Question:

1. What is \arraybackslash for? It seems so mysterious for me.
2. Why must I insert \arraybackslash in place labeled (3) that is shown in my code snippet below? Why must it be put in place (3) rather than (1), (2), or (4)?

\documentclass{minimal}
\usepackage[a4paper,margin=10mm,showframe]{geometry}
\usepackage{lipsum,calc,xcolor}
\usepackage{array,longtable}
\setlength{\tabcolsep}{5mm}
\setlength{\arrayrulewidth}{5mm}

\newcolumntype{A}[1]
{%
>{%
\begin{minipage}{#1\textwidth-1.5\arrayrulewidth-2\tabcolsep}%
\vspace{\tabcolsep}%
}%
c%
<{%
\vspace{\tabcolsep}%
\end{minipage}%
}%
}%
\begin{document}
\color{red}%
\begin{longtable}{%
|%
%>{\arraybackslash}%(1) => Not Needed
A{0.5}%
%<{\arraybackslash}%(2) => Not Needed
|%
>{\arraybackslash}% (3) => Mandatory!
A{0.5}%
%<{\arraybackslash}%(4) => Not Needed
|%
}%
\hline
\lipsum[1] & \lipsum[2]\\\hline
\lipsum[1] & \lipsum[2]\\\hline
\lipsum[1] & \lipsum[2]\\\hline
\end{longtable}
\end{document}


do not use the minipage, it does a lot of redefinitions. A p-column does the same:

\documentclass{minimal}
\usepackage[a4paper,margin=10mm,showframe]{geometry}
\usepackage{lipsum,xcolor}
\usepackage{array,longtable}
\setlength\tabcolsep{5mm}
\setlength\arrayrulewidth{5mm}

\newcolumntype{A}[1]{>{\rule{0pt}{4ex}}p{\dimexpr#1\textwidth-1.5\arrayrulewidth-2\tabcolsep}%
<{\vspace{\tabcolsep}}}%
\begin{document}
\color{red}%
\begin{longtable}{|A{0.5}|A{0.5}|}\hline
\lipsum[1] & \lipsum[2]\\\hline
\lipsum[1] & \lipsum[2]\\\hline
\lipsum[1] & \lipsum[2]\\\hline
\end{longtable}

\end{document}

• Did you mean \hspace{\tabcolsep}? – TH. Dec 26 '10 at 11:08
• why did you use "asymmetric" vertical spaces--- \rule{0pt}{4ex} at the top but \vspace{\tabcolsep} at the bottom? Thanks. – xport Dec 26 '10 at 11:10
• Oh, I think I see what you're trying to do. You want the text to have a margin of \tabcolsep on all sides. – TH. Dec 26 '10 at 11:14
• @TH, yes. I want the contents to be vertically and horizontally centered. And the tallest cell in a row will get the same 4 margins. – xport Dec 26 '10 at 11:15
• thanks for answering. I get your point. Forget \arraybackslash and always use \tabularnewline. But I insist on using minipage rather than p{} because I want to get symmetric margins and to allow the cells to be occupied by \lstinputlisting or \begin{lstlisting}...\end{lstlisting}. – xport Dec 26 '10 at 12:50

\arraybackslash resets the definition of \\ to \tabularnewline.

\let\\\tabularnewline


The minipage environment changes the definition of \\ (presumably), so \arraybackslash resets it.

• But why must it be put in place (3) rather than (1), or (2), or (4)? See my code snippet above for the details. It is self-explanatory. :-) Thank you. – xport Dec 26 '10 at 11:02
• in short: in the last column TeX didn't know what \\ should be: a newline in the column or a new line of the tabular ... – user2478 Dec 26 '10 at 11:05
• @Herbert, why not in place (1) or (2) instead (if (4) does not make sense) ? – xport Dec 26 '10 at 11:07
• that depends to the array package and to the complecated environment in a tabular, because the \\ can also be used inside a math environment like align. However, it is a good idea to use \tabularnewline for a new tabularline. – user2478 Dec 26 '10 at 11:39