File indexing completed on 2024-11-24 04:34:44

0001 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
0002 <html>
0003 <!-- This document is an unofficial reference manual for LaTeX, a
0004 document preparation system, version of November 2018.
0005 
0006 This manual was originally translated from LATEX.HLP v1.0a in the
0007 VMS Help Library.  The pre-translation version was written by
0008 George D. Greenwade of Sam Houston State University.  The
0009 LaTeX 2.09 version was written by Stephen Gilmore.  The
0010 LaTeX2e version was adapted from this by Torsten Martinsen.  Karl
0011 Berry made further updates and additions, and gratefully acknowledges
0012 using Hypertext Help with LaTeX, by Sheldon Green, and
0013 LaTeX Command Summary (for LaTeX 2.09) by
0014 L. Botway and C. Biemesderfer (published by the TeX Users
0015 Group as TeXniques number 10), as reference material.  We also
0016 gratefully acknowledge additional material appearing in
0017 latex2e-reference by Martin Herbert Dietze.  (From these references no
0018 text was directly copied.)
0019 
0020 Copyright 2007, 2008, 2009, 2010, 2011, 2012, 2013,
0021 2014, 2015, 2016, 2017, 2018 Karl Berry.
0022 
0023 Copyright 1988, 1994, 2007 Stephen Gilmore.
0024 
0025 Copyright 1994, 1995, 1996 Torsten Martinsen.
0026 
0027 Permission is granted to make and distribute verbatim copies of
0028 this manual provided the copyright notice and this permission notice
0029 are preserved on all copies.
0030 
0031 
0032 Permission is granted to copy and distribute modified versions of this
0033 manual under the conditions for verbatim copying, provided that the entire
0034 resulting derived work is distributed under the terms of a permission
0035 notice identical to this one.
0036 
0037 Permission is granted to copy and distribute translations of this manual
0038 into another language, under the above conditions for modified versions. -->
0039 <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
0040 <head>
0041 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
0042 <title>tabular (LaTeX2e unofficial reference manual (November 2018))</title>
0043 
0044 <meta name="description" content="tabular (LaTeX2e unofficial reference manual (November 2018))">
0045 <meta name="keywords" content="tabular (LaTeX2e unofficial reference manual (November 2018))">
0046 <meta name="resource-type" content="document">
0047 <meta name="distribution" content="global">
0048 <meta name="Generator" content="makeinfo">
0049 <link href="index.html#Top" rel="start" title="Top">
0050 <link href="IndexDocument.html#Index" rel="index" title="Index">
0051 <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
0052 <link href="Environments.html#Environments" rel="up" title="Environments">
0053 <link href="_005cmulticolumn.html#g_t_005cmulticolumn" rel="next" title="\multicolumn">
0054 <link href="table.html#table" rel="prev" title="table">
0055 <style type="text/css">
0056 <!--
0057 /* $Id: latex2e.css 690 2018-09-15 15:20:19Z jimhefferon $
0058    Minor css for latexrefman. Public domain.
0059    Originally written by Jim Hefferon and Karl Berry, 2018. */
0060 
0061 /* So you can style for yourself */
0062 @import url("/css/latexreflocal.css");
0063 
0064 
0065 
0066 a.summary-letter {text-decoration: none}
0067 blockquote.indentedblock {margin-right: 0em}
0068 blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
0069 blockquote.smallquotation {font-size: smaller}
0070 div.display {margin-left: 3.2em}
0071 div.example {margin-left: 3.2em}
0072 div.lisp {margin-left: 3.2em}
0073 div.smalldisplay {margin-left: 3.2em}
0074 div.smallexample {margin-left: 3.2em}
0075 div.smalllisp {margin-left: 3.2em}
0076 kbd {font-style: oblique}
0077 pre.display {font-family: inherit}
0078 pre.format {font-family: inherit}
0079 pre.menu-comment {font-family: serif}
0080 pre.menu-preformatted {font-family: serif}
0081 pre.smalldisplay {font-family: inherit; font-size: smaller}
0082 pre.smallexample {font-size: smaller}
0083 pre.smallformat {font-family: inherit; font-size: smaller}
0084 pre.smalllisp {font-size: smaller}
0085 span.nolinebreak {white-space: nowrap}
0086 span.roman {font-family: initial; font-weight: normal}
0087 span.sansserif {font-family: sans-serif; font-weight: normal}
0088 ul.no-bullet {list-style: none}
0089 BODY {
0090   margin-top: 1em;
0091   margin-left: 1em; /* auto results in two-digit <ol> lost off left */
0092   margin-right: 1em;
0093   margin-bottom: 1em;
0094   /* the idea is to use the whole window, unless it is ridiculously
0095      wide, probably with too-small fonts, too.  */
0096   max-width: 64em;
0097 }
0098 
0099 /* Because we want @math{... @code ...} to be upright, not slanted,
0100    and Texinfo won't fix it. */
0101 code {font-style:normal; font-family:monospace; }
0102 
0103 /* We put a link to our own home page at the bottom. */
0104 div.referenceinfo {font-size:small;}
0105 
0106 -->
0107 </style>
0108 
0109 
0110 </head>
0111 
0112 <body lang="en">
0113 <a name="tabular"></a>
0114 <div class="header">
0115 <p>
0116 Next: <a href="thebibliography.html#thebibliography" accesskey="n" rel="next">thebibliography</a>, Previous: <a href="table.html#table" accesskey="p" rel="prev">table</a>, Up: <a href="Environments.html#Environments" accesskey="u" rel="up">Environments</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="IndexDocument.html#Index" title="Index" rel="index">Index</a>]</p>
0117 </div>
0118 <hr>
0119 <a name="tabular-1"></a>
0120 <h3 class="section">8.23 <code>tabular</code></h3>
0121 
0122 <a name="index-environment_002c-tabular"></a>
0123 <a name="index-tabular-environment"></a>
0124         
0125 <a name="index-lines-in-tables"></a>
0126 <a name="index-lining-text-up-in-tables"></a>
0127 
0128 <p>Synopsis:
0129 </p>
0130 <div class="example">
0131 <pre class="example">\begin{tabular}[<var>pos</var>]{<var>cols</var>}
0132   <var>column 1 entry</var>  &amp;<var>column 2 entry</var>  ...  &amp;<var>column n entry</var> \\
0133   ...
0134 \end{tabular}
0135 </pre></div>
0136 
0137 <p>or
0138 </p>
0139 <div class="example">
0140 <pre class="example">\begin{tabular*}{<var>width</var>}[<var>pos</var>]{<var>cols</var>}
0141   <var>column 1 entry</var>  &amp;<var>column 2 entry</var>  ...  &amp;<var>column n entry</var> \\
0142   ...
0143 \end{tabular*}
0144 </pre></div>
0145 
0146 <p>Produce a table, a box consisting of a sequence of horizontal rows.
0147 Each row consists of items that are aligned vertically in columns.  This
0148 illustrates many of the features.
0149 </p>
0150 <div class="example">
0151 <pre class="example">\begin{tabular}{l|l}
0152   \textit{Player name}  &amp;\textit{Career home runs}  \\ 
0153   \hline
0154   Hank Aaron  &amp;755 \\
0155   Babe Ruth   &amp;714
0156 \end{tabular}
0157 </pre></div>
0158 
0159 <p>The output will have two left-aligned columns with a vertical bar
0160 between them.  This is specified in <code>tabular</code>&rsquo;s argument
0161 <code>{l|l}</code>.
0162 <a name="index-_0026"></a>
0163 Put the entries into different columns by separating them with an
0164 ampersand, <code>&amp;</code>.  The end of each row is marked with a double
0165 backslash, <code>\\</code>.  Put a horizontal rule below a row, after a double
0166 backslash, with <code>\hline</code>.
0167 <a name="index-_005c_005c-for-tabular"></a>
0168 After the last row the <code>\\</code> is optional, unless an <code>\hline</code>
0169 command follows to put a rule below the table.
0170 </p>
0171 <p>The required and optional arguments to <code>tabular</code> consist of:
0172 </p>
0173 <dl compact="compact">
0174 <dt><var>pos</var></dt>
0175 <dd><p>Optional.  Specifies the table&rsquo;s vertical position.  The default is to
0176 align the table so its vertical center matches the baseline of the
0177 surrounding text.  There are two other possible alignments: <code>t</code>
0178 aligns the table so its top row matches the baseline of the surrounding
0179 text, and <code>b</code> aligns on the bottom row.
0180 </p>
0181 <p>This only has an effect if there is other text.  In the common case of a
0182 <code>tabular</code> alone in a <code>center</code> environment this option makes
0183 no difference.
0184 </p>
0185 </dd>
0186 <dt><var>cols</var></dt>
0187 <dd><p>Required.  Specifies the formatting of columns.  It consists of a
0188 sequence of the following specifiers, corresponding to the types of
0189 column and intercolumn material.
0190 </p>
0191 <dl compact="compact">
0192 <dt><code>l</code></dt>
0193 <dd><p>A column of left-aligned items.
0194 </p>
0195 </dd>
0196 <dt><code>r</code></dt>
0197 <dd><p>A column of right-aligned items.
0198 </p>
0199 </dd>
0200 <dt><code>c</code></dt>
0201 <dd><p>A column of centered items.
0202 </p>
0203 </dd>
0204 <dt><code>|</code></dt>
0205 <dd><p>A vertical line the full height and depth of the environment.
0206 </p>
0207 </dd>
0208 <dt><code>@{<var>text or space</var>}</code></dt>
0209 <dd><p>Insert <var>text or space</var> at this location in every row.  The <var>text
0210 or space</var> material is typeset in LR mode.  This text is fragile
0211 (see <a href="_005cprotect.html#g_t_005cprotect">\protect</a>).
0212 </p>
0213 <p>If between two columns there is no @-expression then LaTeX&rsquo;s
0214 <code>book</code>, <code>article</code>, and <code>report</code> classes will put on
0215 either side of each column a space of length <code>\tabcolsep</code>, which by
0216 default is 6pt.  That is, by default adjacent columns are
0217 separated by 12pt (so <code>\tabcolsep</code> is misleadingly named
0218 since it is only half of the separation between tabular columns).  In
0219 addition, a space of 6pt also comes before the first column and
0220 after the final column, unless you put a <code>@{...}</code> or <code>|</code>
0221 there.
0222 </p>
0223 <p>If you override the default and use an @-expression then LaTeX does
0224 not insert <code>\tabcolsep</code> so you must insert any desired space
0225 yourself, as in <code>@{\hspace{1em}}</code>.
0226 </p>
0227 <p>An empty expression <code>@{}</code> will eliminate the space. In
0228 particular, sometimes you want to eliminate the space before the first
0229 column or after the last one, as in the example below where the
0230 tabular lines need to lie on the left margin.
0231 </p>
0232 <div class="example">
0233 <pre class="example">\begin{flushleft}
0234   \begin{tabular}{@{}l}
0235     ...
0236   \end{tabular}
0237 \end{flushleft}
0238 </pre></div>
0239 
0240 <p>The next example shows text, a decimal point between the columns,
0241 arranged so the numbers in the table are aligned on it.
0242 </p>
0243 <div class="example">
0244 <pre class="example">\begin{tabular}{r@{$.$}l}
0245   $3$ &amp;$14$  \\
0246   $9$ &amp;$80665$
0247 \end{tabular}
0248 </pre></div>
0249 
0250 <a name="index-_005cextracolsep"></a>
0251 <p>An <code>\extracolsep{<var>wd</var>}</code> command in an @-expression causes an
0252 extra space of width <var>wd</var> to appear to the left of all subsequent
0253 columns, until countermanded by another <code>\extracolsep</code>.  Unlike
0254 ordinary intercolumn space, this extra space is not suppressed by an
0255 @-expression.  An <code>\extracolsep</code> command can be used only in an
0256 @-expression in the <code>cols</code> argument.  Below, LaTeX inserts the
0257 right amount of intercolumn space to make the entire table 4 inches
0258 wide.
0259 </p>
0260 <div class="example">
0261 <pre class="example">\begin{tabular*}{4in}{l@{\extracolsep{\fill}}l}
0262   Seven times down, eight times up \ldots 
0263   &amp;such is life!
0264 \end{tabular*}
0265 </pre></div>
0266 
0267 <p>To insert commands that are automatically executed before a given
0268 column, load the <code>array</code> package and use the <code>&gt;{...}</code>
0269 specifier.
0270 </p>
0271 </dd>
0272 <dt><code>p{<var>wd</var>}</code></dt>
0273 <dd><p>Each item in the column is typeset in a parbox of width <var>wd</var>, as if
0274 it were the argument of a <code>\parbox[t]{wd}{...}</code> command.
0275 </p>
0276 <p>A line break double backslash <code>\\</code> may not appear in the item,
0277 except inside an environment like <code>minipage</code>, <code>array</code>, or
0278 <code>tabular</code>, or inside an explicit <code>\parbox</code>, or in the scope of
0279 a <code>\centering</code>, <code>\raggedright</code>, or <code>\raggedleft</code>
0280 declaration (when used in a <code>p</code>-column element these declarations
0281 must appear inside braces, as with <code>{\centering .. \\
0282 ..}</code>). Otherwise LaTeX will misinterpret the double backslash as
0283 ending the row.  Instead, to get a line break in there use
0284 <code>\newline</code> (see <a href="_005cnewline.html#g_t_005cnewline">\newline</a>).
0285 </p>
0286 </dd>
0287 <dt><code>*{<var>num</var>}{<var>cols</var>}</code></dt>
0288 <dd><p>Equivalent to <var>num</var> copies of <var>cols</var>, where <var>num</var> is a
0289 positive integer and <var>cols</var> is a list of specifiers.  Thus the
0290 specifier <code>\begin{tabular}{|*{3}{l|r}|}</code> is equivalent to
0291 the specifier <code>\begin{tabular}{|l|rl|rl|r|}</code>.  Note that
0292 <var>cols</var> may contain another <code>*</code>-expression.
0293 </p> 
0294 </dd>
0295 </dl>
0296 
0297 </dd>
0298 <dt><var>width</var></dt>
0299 <dd><p>Required for <code>tabular*</code>, not allowed for <code>tabular</code>. Specifies
0300 the width of the <code>tabular*</code> environment.  The space between columns
0301 should be rubber, as with <code>@{\extracolsep{\fill}}</code>, to allow
0302 the table to stretch or shrink to make the specified width, or else you
0303 are likely to get the <code>Underfull \hbox (badness 10000) in alignment
0304 ...</code> warning.
0305 </p>
0306 </dd>
0307 </dl>
0308 
0309 <p>Parameters that control formatting:
0310 </p>
0311 <dl compact="compact">
0312 <dt><code>\arrayrulewidth</code>
0313 <a name="index-_005carrayrulewidth"></a>
0314 </dt>
0315 <dd><a name="tabular-arrayrulewidth"></a><p>A length that is the thickness of the rule created by <code>|</code>,
0316 <code>\hline</code>, and <code>\vline</code> in the <code>tabular</code> and <code>array</code>
0317 environments.  The default is &lsquo;<samp>.4pt</samp>&rsquo;. Change it as in
0318 <code>\setlength{\arrayrulewidth}{0.8pt}</code>.
0319 </p>
0320 </dd>
0321 <dt><code>\arraystretch</code>
0322 <a name="index-_005carraystretch"></a>
0323 </dt>
0324 <dd><a name="tabular-arraystrech"></a><p>A factor by which the spacing between rows in the <code>tabular</code> and
0325 <code>array</code> environments is multiplied.  The default is &lsquo;<samp>1</samp>&rsquo;, for
0326 no scaling.  Change it as <code>\renewcommand{\arraystretch}{1.2}</code>.
0327 </p>
0328 </dd>
0329 <dt><code>\doublerulesep</code>
0330 <a name="index-_005cdoublerulesep"></a>
0331 </dt>
0332 <dd><a name="tabular-doublerulesep"></a><p>A length that is the distance between the vertical rules produced by the
0333 <code>||</code> specifier.  The default is &lsquo;<samp>2pt</samp>&rsquo;.
0334 </p>
0335 </dd>
0336 <dt><code>\tabcolsep</code>
0337 <a name="index-_005ctabcolsep"></a>
0338 </dt>
0339 <dd><a name="tabular-tabcolsep"></a><p>A length that is half of the space between columns. The default is
0340 &lsquo;<samp>6pt</samp>&rsquo;.  Change it with <code>\setlength</code>.
0341 </p>
0342 </dd>
0343 </dl>
0344 
0345 <p>The following commands can be used inside the body of a <code>tabular</code>
0346 environment, the first two inside an entry and the second two between
0347 lines:
0348 </p>
0349 <table class="menu" border="0" cellspacing="0">
0350 <tr><td align="left" valign="top">&bull; <a href="_005cmulticolumn.html#g_t_005cmulticolumn" accesskey="1">\multicolumn</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Make an item spanning several columns.
0351 </td></tr>
0352 <tr><td align="left" valign="top">&bull; <a href="_005cvline.html#g_t_005cvline" accesskey="2">\vline</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Draw a vertical line.
0353 </td></tr>
0354 <tr><td align="left" valign="top">&bull; <a href="_005ccline.html#g_t_005ccline" accesskey="3">\cline</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Draw a horizontal line spanning some columns.
0355 </td></tr>
0356 <tr><td align="left" valign="top">&bull; <a href="_005chline.html#g_t_005chline" accesskey="4">\hline</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Draw a horizontal line spanning all columns.
0357 </td></tr>
0358 </table>
0359 
0360 
0361 
0362 
0363 <hr/><div class='referenceinfo'> <a href='https://latexref.xyz/'> <i>Unofficial LaTeX2e reference manual</i></a></div>
0364 </body>
0365 </html>