summaryrefslogtreecommitdiff
path: root/Master/texmf-doc/doc/english/FAQ-en/html/FAQ-tabcellalign.html
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-doc/doc/english/FAQ-en/html/FAQ-tabcellalign.html')
-rw-r--r--Master/texmf-doc/doc/english/FAQ-en/html/FAQ-tabcellalign.html109
1 files changed, 109 insertions, 0 deletions
diff --git a/Master/texmf-doc/doc/english/FAQ-en/html/FAQ-tabcellalign.html b/Master/texmf-doc/doc/english/FAQ-en/html/FAQ-tabcellalign.html
new file mode 100644
index 00000000000..bf41eb54fe4
--- /dev/null
+++ b/Master/texmf-doc/doc/english/FAQ-en/html/FAQ-tabcellalign.html
@@ -0,0 +1,109 @@
+<head>
+<title>UK TeX FAQ -- question label tabcellalign</title>
+</head><body>
+<h3>How to alter the alignment of tabular cells</h3>
+<p>One often needs to alter the alignment of a tabular <code>p</code> ('paragraph')
+cell, but problems at the end of a table row are common. With a
+<code>p</code> cell that looks like:
+<blockquote>
+<pre>
+... & \centering blah ... \\
+</pre>
+</blockquote>
+one is liable to encounter errors that complain about a "misplaced
+<code>\</code><code>noalign</code>" or "<a href="FAQ-altabcr.html">extra alignment tab</a>", or the like.
+The problem is that the command <code>\\</code> means different things in
+different circumstances: the <code>tabular</code> environment
+switches the meaning to a value for use in the table, and
+<code>\</code><code>centering</code>, <code>\</code><code>raggedright</code> and <code>\</code><code>raggedleft</code> 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 <code>&amp;</code> (or <code>\\</code>) that
+terminates it.
+<p>The simple (old) solution is to preserve the meaning of <code>\\</code>:
+<blockquote>
+<pre>
+\newcommand\PBS[1]{\let\temp=\\%
+ #1%
+ \let\\=\temp
+}
+</pre>
+</blockquote>
+which one uses as:
+<blockquote>
+<pre>
+... & \PBS\centering blah ... \\
+</pre>
+</blockquote>
+(for example).
+<p>The technique using <code>\</code><code>PBS</code> was developed in the days of LaTeX 2.09
+because the actual value of <code>\\</code> that the <code>tabular</code>
+environment uses was only available as an internal command. Nowadays,
+the value is a public command, and you can in principle use it
+explicitly:
+<blockquote>
+<pre>
+... & \centering blah ... \tabularnewline
+</pre>
+</blockquote>
+which may be incorporated into a simple macro as:
+<blockquote>
+<pre>
+\newcommand{\RBS}{\let\\=\tabularnewline}
+...
+... & \centering\RBS blah ... \\
+</pre>
+</blockquote>
+and used as
+<blockquote>
+<pre>
+... & \centering\RBS blah ... \\
+</pre>
+</blockquote>
+(note, you Preserve backslash with <code>\</code><code>PBS</code> <em>before</em> the command
+that changes it, and Restore it with <code>\</code><code>RBS</code> <em>after</em> the
+command; in fact, <code>\</code><code>RBS</code> is marginally preferable, but the old
+trick lingers on).
+<p>The <code>\</code><code>PBS</code> and <code>\</code><code>RBS</code> tricks also serve well in <i>array</i>
+package "field format" preamble specifications:
+<blockquote>
+
+<pre>
+\begin{tabular}{... &gt;{\centering\RBS}p{50mm}}
+...
+</pre>
+</blockquote>
+or
+<blockquote>
+
+</blockquote>
+<blockquote>
+<pre>
+\begin{tabular}{... &gt;{\PBS\centering}p{50mm}}
+...
+</pre>
+</blockquote>
+In the <i>tabularx</i> and <i>tabulary</i> packages, there's a
+command <code>\</code><code>arraybackslash</code> that has same effect as <code>\</code><code>RBS</code> (above);
+so in those packages, one might say:
+<blockquote>
+
+<pre>
+\begin{tabular}{... &gt;{\centering\arraybackslash}p{50mm}}
+...
+</pre>
+</blockquote>
+in place of the example above; in fact, the very latest (2003/12/01)
+release of array.sty also provides a <code>\</code><code>tabularnewline</code> command,
+that has the "basic tabular/array" meaning of '\\'.
+
+The command does rather lack brevity, but at least you don't have to
+define it for yourself.
+<dl>
+<dt><tt><i>array.sty</i></tt><dd>Distributed as part of <a href="ftp://cam.ctan.org/tex-archive/macros/latex/required/tools.zip">macros/latex/required/tools</a> (<a href="ftp://cam.ctan.org/tex-archive/macros/latex/required/tools.tar.gz">gzipped tar</a>, <a href="http://www.tex.ac.uk/tex-archive/macros/latex/required/tools/">browse</a>)
+<dt><tt><i>tabularx.sty</i></tt><dd>Distributed as part of <a href="ftp://cam.ctan.org/tex-archive/macros/latex/required/tools.zip">macros/latex/required/tools</a> (<a href="ftp://cam.ctan.org/tex-archive/macros/latex/required/tools.tar.gz">gzipped tar</a>, <a href="http://www.tex.ac.uk/tex-archive/macros/latex/required/tools/">browse</a>)
+<dt><tt><i>tabulary.sty</i></tt><dd>Distributed as part of <a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/carlisle.zip">macros/latex/contrib/carlisle</a> (<a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/carlisle.tar.gz">gzipped tar</a>, <a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/carlisle/">browse</a>)
+</dl>
+
+<p><p>This question on the Web: <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=tabcellalign">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=tabcellalign</a>
+</body>