The \arraybackslash
was used on answer table at How to auto adjust my last table column width, and why is there Underfull \vbox badness on this table?
\documentclass[10pt,a5paper,twoside]{memoir}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}
\usepackage{ragged2e}
\usepackage[showframe,pass]{geometry}
\usepackage{ltablex}
\keepXColumns
\begin{document}
\frenchspacing
\setlength\extrarowheight{2pt}
\begin{tabularx}{\linewidth}{|>{\RaggedRight}p{3cm}|>{\arraybackslash}X|}
\caption{Formatação do texto}
\label{tab:a_table_formatacao_de_texto} \\
\hline
\endfirsthead
\multicolumn{2}{c}{\tablename~\thetable: Formatação do texto (continued)} \\
\hline
\endhead
\hline
\multicolumn{2}{r}{\footnotesize to be continued}
\endfoot
\hline
\endlastfoot
Cor & Branco - \\ \hline
Formato do papel & A5 \\ \hline
Gramatura & 75 \\ \hline
Cabeçalho & 0,7 \\ \hline
Impressão & Frente e verso \\ \hline
Margens & Espelhadas: superior 2, Inferior: 1,5 \\ \hline
Cabeçalho & 0,7 \\ \hline
Rodapé & 0,7 \\ \hline
Paginação & Externa \\ \hline
Alinhamento vertical & Superior \\ \hline
Cabeçalho & 0,7 \\ \hline
Alinhamento do texto & Justificado \\ \hline
Cor & Branco - \\ \hline
Formato do papel & A5 \\ \hline
Cabeçalho & 0,7 \\ \hline
Gramatura & 75 \\ \hline
Impressão & Frente e verso \\ \hline
Margens & Espelhadas: superior 2, Inferior: 1,5 \\ \hline
Rodapé & 0,7 \\ \hline
Paginação & Externa \\ \hline
Alinhamento vertical & Superior \\ \hline
Alinhamento do texto & Justificado \\ \hline
\end{tabularx}
\end{document}
On the question Difference between \\ and \tabularnewline there is some explaining about it:
\arraybackslash
: Restore\\
for use in array and tabular
environment (after\raggedright
etc.).\def\arraybackslash{\let\\\tabularnewline}
Why \\
is broken by \raggedright
and these etc other commands?
Reading the line \def\arraybackslash{\let\\\tabularnewline}
seems the \\
is being redefined as \tabularnewline
, does \raggedright
and these etc other commands redefine it as something else, why?
Does I need to put \arraybackslash
only on my last table column? What happens if I do not put it or put on/only a middle column or put on every column?
Best Answer
As with almost everything in TeX, control sequences (macros and control words) can be redefined, and because local grouping allows for local redefinition, the definitions of macros within a particular environment can be different from the definitions outside of that environment. This is the case of
\\
, which has multiple definitions depending on the environment.In normal text,
\\
is defined as:Inside a tabular environment, it is defined as:
which expands to:
Inside a
raggedright
environment,\\
is redefined to bewhich expands to:
Since these definitions are different, after using a
\raggedright
environment in atabular
you need to use\arraybackslash
to restore it to itstabular
definition.In addition to the question you linked to, see also: