Sideway
output.to from Sideway
Draft for Information Only

Content

LaTeX Table
table Environment
  Commands
   table Environment
    Parameter placement
    body of the table
   \caption Command
   \label Command
  Example
   Code
   Output
tabular Environment
  Commands
   tabular Environment
    Parameter width
    Parameter pos
    Parameter cols
 Source and Reference

LaTeX Table

There are two LaTeX environments for typesetting tables: table and tabular. The table environment is a container designed for holding tabular environments. While the tablular environment is a container designed for typesetting material in rows and columns. A LaTeX table is a float and is not part of the normal stream. LaTeX floats tables according to the specified position or the available space on the page at the point of processing automatically.

table Environment

A table environment is a float with environment name table. A table environment contains a \caption command and may be followed by a label command.

Commands

table Environment

\begin{table}[placement]
    ⋯body of the table⋯
\end{table}
Parameter placement
The default placement identifer for report and article styles is [tbp], which means LaTeX is allowed to place the figure at the top of the page/column; bottom of the page/column; or if the float is quite tall (including the caption), all on its own on a float page without any text. Tables will not be split between two pages. Optional values are hplaces the table Here, where the table environment appears. tplaces the table at the Top of a text page bplaces the table at the Bottom of text page pplaces the table in a separate float Page without any text !is used in addition to other arguments informs LaTeX to override its default table placement values
body of the table
The body of the table is made up of whatever text, LaTeX commands, etc.,

\caption Command

\caption is used to specify the title of a table at the point of processing. Numbering of table is automatic.
\caption[short caption]{long caption}

\label Command

\label is used to specify the reference name of a table, such that the corresponding can be referred to with the \ref command. However, \label command must be placed after the \caption command
\label{table name}

Example

Code

\documentclass{article}
\usepackage[paperwidth=10cm,paperheight=6.4cm,top=0.2cm,bottom=0.2cm,left=0.2cm, right=0.2cm,showframe]{geometry}

\begin{document}
\begin{table}[ht]
\caption{With Placement Specifier: ht}
\centering 
\begin{tabular}{c}
\hline
Column\\
\hline
a\\
\hline
\end{tabular}
\label{table: One}
\end{table}
\begin{table}[b!]
\centering 
\begin{tabular}{c c c c}
\hline
Column \#1 & Column \#2 & Column \#3 & Column \#4 \\
\hline
a & b & c & d \\
\hline
\end{tabular}
\caption{With Placement Specifier: b!}
\label{table: Two}
\end{table}
Table \ref{table: One}, Table \ref{table: Two},
And Table \ref{table: Three}.
\begin{table}[htbp!]
\caption{With Placement Specifier: htbp!}
\label{table: Three}
\end{table}
\end{document}

Output

image

tabular Environment

A tabular environment is used to typeset tabular matter in a table environment or elsewhere. The argument of how many columns and types of columns must be specified when typesetting a tabular Environment. And the tabular matter is a sequence of rows of item, which are aligned vertically in columns.

Commands

tabular Environment

\begin{tabular}[pos]{cols}
    ⋯sequence of rows⋯
\end{tabular}
\begin{tabular*}{width}[pos]{cols}
    ⋯
\end{tabular*}
Parameter width
Parameter width is used to specify the width of the tabular* environment. There must be rubber space between columns than can be stretch to fill out the specified width.
Example
Code
\documentclass{article}
\usepackage[paperwidth=10cm,paperheight=5.15cm,top=0.2cm,bottom=0.2cm,left=0.2cm, right=0.2cm,showframe]{geometry}

\begin{document}
\begin{table}[ht]
\centering 
\caption{With Placement Specifier: ht}
\label{table: One}
\begin{tabular*}{0.8\textwidth}{|l|c|@{\extracolsep{\fill}}r|}
\hline
Column \#1 & Column \#2 & Column \#3 \\
\hline
a & b & c \\
\hline
\end{tabular*}
\end{table}
\begin{table}[b!]
\centering 
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}|l|c|r|}
\hline
Column \#1 & Column \#2 & Column \#3 \\
\hline
a & b & c \\
\hline
\end{tabular*}
\caption{With Placement Specifier: b!}
\label{table: Two}
\end{table}
\end{document}
Output image
Parameter pos
Parameter pos is used to specify the vertical alignment of the tabularenvironment with respect to text flow. The default value is c, that is alignment of the center of the tabular environment. Optional values are talign on top row balign on bottom row calign on center of the enviroment (default)
Example
Code
\documentclass[margin=10pt]{standalone}

\begin{document}
Default:
\begin{tabular}{c}
    H \\ H\\
\end{tabular}
Center (pos=c):
\begin{tabular}[c]{c}
    H \\ H\\
\end{tabular}
Top (pos=t):
\begin{tabular}[t]{c}
    H \\ H\\
\end{tabular}
Bottom (pos=b):
\begin{tabular}[b]{c}
    H \\ H\\
\end{tabular}
H
\end{document}
Output image
Parameter cols
Parameter col is used to specify the column formatting of a tabular environment by assigning a sequence of specifiers, corresponding to the sequence of columns and intercolumn material. Optional values are lA column of left-aligned items. rA column of right-aligned items cA column of centered items |A vertical line the full height and depth of the environment. ||A double vertical line the full height and depth of the environment. @{text}This inserts text in every row. An @-expression suppresses the intercolumn space normally inserted between columns; any desired space between the inserted text and the adjacent items must be included in text. An \extracolsep{wd} command in an @-expression causes an extra space of width wd to appear to the left of all subsequent columns, until countermanded by another \extracolsep command. Unlike ordinary intercolumn space, this exta space is not suppressed by an @-expression. An \extracolsep command can be used only in an @-expression in the cols argument. p{wd}Produces a column with each item typeset in a parbox of width wd, as if it were the argument of a \parbox[t]{wd} command. However, a \\ may not appear in the item, except in the following situations: inside an environment like minipage, array, or tabular. inside an explicit \parbox in the scope of a \centering, \raggedright, or \raggedleft declaration. The latter declarations must appear inside braces or an environment when used in a p=column element *{num}{cols}Equivalent to num copies of cols, where num is any positive integer and cols is any list of column-specifiers, which may contain another *-expression.
Example Tabular Columns 1
Code
\documentclass{article}
\usepackage[paperwidth=10.5cm,paperheight=10cm,top=0.2cm,bottom=0.2cm,left=0.2cm, right=0.2cm,showframe]{geometry}

\begin{document}
\begin{table}[ht]
\centering 
\caption{With Placement Specifier: ht}
\begin{tabular}{lccr}
\hline
Column \#1 & Column \#2 & Column \#3 & Column \#4 \\
\hline
a & b & c & d\\
\hline
\end{tabular}
\end{table}
\begin{table}[ht!]
\centering 
\caption{With Placement Specifier: ht!}
\begin{tabular}{|lc||c|r}
\hline
Column \#1 & Column \#2 & Column \#3 & Column \#4 \\
\hline
a & b & c & d\\
\hline
\end{tabular}
\end{table}
\begin{table}[hb!]
\centering 
\begin{tabular}{|@{}l|@{$\vert$}c@{ H.}c@{}r@{Z}||}
\hline
Column \#1 & Column \#2 & Column \#3 & Column \#4 \\
\hline
a & b & c & d\\
\hline
\end{tabular}
\caption{With Placement Specifier: hb!}
\end{table}
\begin{table}[htb!]
\centering 
\begin{tabular}{@{\extracolsep{1em}}|l|l|@{\extracolsep{1em}}l|l|@{\extracolsep{0em}}l|}
\hline
Col \#1 & Col \#2 & Col \#3 & Col \#4 & Col \#5 \\
\hline
H1emp & H & H1em & H & H0em\\
\hline
\end{tabular}
\caption{With Placement Specifier: htb!}
\end{table}
\end{document}
Output image
Example Tabular Columns 2
Code
\documentclass{article}
\usepackage[paperwidth=16.5cm,paperheight=11.5cm,top=0.2cm,bottom=0.2cm,left=0.2cm, right=0.2cm,showframe]{geometry}

\begin{document}
\begin{table}[ht]
\centering 
\caption{With Placement Specifier: ht}
\begin{tabular}{|l|c|c|c|r|}
\hline
Col \#1 & Col \#2 & Col \#3 & Col \#4 & Col \#5 \\
\hline
HHH & HHH & HHH & HHH & HHH \\
\hline
\end{tabular}
\end{table}
\begin{table}[ht!]
\centering 
\caption{With Placement Specifier: ht!}
\begin{tabular}{|l|p{5em}|c|p{\dimexpr 0.15\linewidth-2\tabcolsep}|r|}
\hline
Col \#1 & Col \#2 & Col \#3 & Col \#4 & Col \#5 \\
\hline
HHH HH HHHH & HHH HH HHHH & HHH HH HHHH & HHH HH HHHH & HHH HH HHHH\\
\hline
\end{tabular}
\end{table}
\begin{table}[hb!]
\centering 
\begin{tabular}{*{4}{|p{\dimexpr 0.15\linewidth-2\tabcolsep}}|r|}
\hline
Col \#1 & Col \#2 & Col \#3 & Col \#4 & Col \#5 \\
\hline
HHH HH HHHH & HHH HH HHHH & HHH HH HHHH & HHH HH HHHH & HHH HH HHHH\\
\hline
\end{tabular}
\caption{With Placement Specifier: hb!}
\end{table}
\begin{table}[htb!]
\centering 
\begin{tabular}{|*{5}{|p{\dimexpr 0.15\linewidth-2\tabcolsep}|}|}
\hline
Col \#1 & Col \#2 & Col \#3 & Col \#4 & Col \#5 \\
\hline
HHH HH HHHH & HHH HH HHHH & HHH HH HHHH & HHH HH HHHH & HHH HH HHHH\\
\hline
\end{tabular}
\caption{With Placement Specifier: htb!}
\end{table}
\end{document}
Output image

Source and Reference


©sideway

ID: 220400026 Last Updated: 4/26/2022 Revision: 0


Latest Updated LinksValid XHTML 1.0 Transitional Valid CSS!Nu Html Checker Firefox53 Chromena IExplorerna
IMAGE

Home 5

Business

Management

HBR 3

Information

Recreation

Hobbies 8

Culture

Chinese 1097

English 339

Reference 79

Computer

Hardware 249

Software

Application 213

Digitization 32

Latex 52

Manim 205

KB 1

Numeric 19

Programming

Web 289

Unicode 504

HTML 66

CSS 65

SVG 46

ASP.NET 270

OS 429

DeskTop 7

Python 72

Knowledge

Mathematics

Formulas 8

Algebra 84

Number Theory 206

Trigonometry 31

Geometry 34

Coordinate Geometry 2

Calculus 67

Complex Analysis 21

Engineering

Tables 8

Mechanical

Mechanics 1

Rigid Bodies

Statics 92

Dynamics 37

Fluid 5

Fluid Kinematics 5

Control

Process Control 1

Acoustics 19

FiniteElement 2

Natural Sciences

Matter 1

Electric 27

Biology 1

Geography 1


Copyright © 2000-2024 Sideway . All rights reserved Disclaimers last modified on 06 September 2019