UK TeX FAQ -- question 175

### How to alter the alignment of tabular cells

One often needs to alter the alignment of a tabular `p` ('paragraph') cell, but problems at the end of a table row are common. If we have a `p` cell that looks like

    ... & \centering blah ... \\

one is liable to encounter errors that complain about a "misplaced `\noalign`" (or the like). The problem is that the command `\``\` means different things in different circumstances: the `tabular` environment switches the meaning to a value for use in the table, and `\centering`, `\flushright` and `\flushleft` all change the meaning to something incompatible. Note that the problem only arises in the last cell of a row: since each cell is set into a box, its settings are lost at the `&` (or `\``\`) that terminates it.

The simple (old) solution is to preserve the meaning of `\``\`:

    \def\PBS#1{\let\temp=\\%
      #1%
      \let\\=\temp
    }

which one uses as:

    ... & \PBS\centering blah ... \\

(for example).

The technique using `\PBS` was developed in the days of LaTeX 2.09 because the actual value of `\``\` that the `tabular` environment used was only available as an internal command. Nowadays, the value is a public command, and you can in principle use it explicitly:

    ... & \centering blah ... \tabularnewline

but the old trick has the advantage of extreme compactness.

The `\PBS` trick also serves well in array package "field format" preamble specifications:

    \begin{tabular}{... >{\PBS\centering}p{50mm}}
    ...

`array.sty`
  Distributed as part of macros/latex/required/tools.tar.gz