Creating Tables

Diese Seite existiert momentan nur auf Englisch.

 

The array - package is an extention of the tabular - environment.

Examples of Preamble Commands

Insert text or functions directly in front of the entry ( > ) or right after the entry ( < )

\documentclass{article}
\usepackage{array}
\begin{document}
\begin{tabular}{|>{\large}c|>{\large\bfseries}l|>{\large}r|}\hline
A & B & C \\ \hline
100 & 10 & 1 \\ \hline
\multicolumn{1}{|c<{~DM}}{100} & \multicolumn{1}{|l<{~DM}}{10} & \multicolumn{1}{|r<{~DM}|}{1} \\ \hline
\end{tabular}
\end{document}



Additional declaration of \extrarowheight adds a vertical space above each row.

\documentclass{article}
\usepackage{array}
\begin{document}
\setlength{\extrarowheight}{4pt}
\begin{tabular}{|>{\large}c|>{\large\bfseries}l|>{\large}r|}
\hline A & B & C\\\hline 100 & 10 & 1 \\ \hline
\multicolumn{1}{|c<{~DM}}{100} &
\multicolumn{1}{|l<{~DM}}{10} &
\multicolumn{1}{|r<{~DM}|}{1} \\ \hline
\end{tabular}

\end{document}

Vertical Alignment

\documentclass{article}
\usepackage{array}
\begin{document}
\begin{tabular}{|p{1cm}|p{1cm}|p{1cm}|}
\hline 1 1 1 1 1 1 1 1 1 1 & 2 2 2 2 2 2 2 & 3 3 3 3 \\ \hline \multicolumn{1}{|m{1cm}}{1 1 1 1 1 1 1 1 1 1} &
\multicolumn{1}{|m{1cm}}{2 2 2 2 2 2 2} &
\multicolumn{1}{|m{1cm}|}{3 3 3 3} \\ \hline
\multicolumn{1}{|b{1cm}}{1 1 1 1 1 1 1 1 1 1} &
\multicolumn{1}{|b{1cm}}{2 2 2 2 2 2 2} &
\multicolumn{1}{|b{1cm}|}{3 3 3 3} \\ \hline
\end{tabular}
\end{document}

Vertical Rules

\documentclass{article}
\usepackage{array}
\begin{document}
\begin{tabular}{|c!{:}c!{\vrule width 3pt}c|} \hline
A & B & C \\ \hline 100 & 10 & 1 \\ \hline
\end{tabular}
\end{document}


Defining New Column Specifiers


You can specify your own columntype.

\newcolumntype{col}[narg]{decl}

col - name of the new columntype
narg - number of arguments
decl - legal declarations

\documentclass{article}
\usepackage{array}
\begin{document}
\newcolumntype{L}{>{$}l<{$}}
\setlength{\extrarowheight}{2pt}
\begin{tabular}{|l|L|c|} \hline
10   & 10^4      & 1000 \\ \hline
1000 & 100^{-99} & 1    \\ \hline
\end{tabular}
\end{document}


Colored cells in a tabular-environment


Cells can be colored in a LaTeX array by using the colortab.sty.

You have to define the colored cell with the commands \LCC ("LaTeXColorCell") and \ECC ("EndColorCell"). If you use multicolumn than you put \SP ("SavePreamble") at the beginning of the array-type environment, and put \RP ("Restore Preamble") at the end of each line containing a \multicolumn command.

 

\documentclass{article}
\usepackage{colortab,array}
\input pstricks
\begin{document}
\renewcommand{\arraystretch}{1.5}
\newcommand{\zw}[1]{%
\LCC
\lightgray & \lightgray \\
\multicolumn{2}{|c|}{#1}\\ \RP \hline
\ECC } \newcommand{\cocell}[2]{% \LCC \lightgray & \red \\ {#1} & {#2}\\\RP \hline \ECC
}
\begin{tabular}{|l|c|}\SP\hline
\zw{Test f\"ur farbige Tabellenzellen}
links1 & rechts1\\ \hline
links2 & rechts2 \\ \hline
links3 & rechts3 \\ \hline
\zw{Programmierung}
links & rechts \\ \hline
\end{tabular}

\begin{tabular}{|l|c|}\SP\hline
\cocell{Test f\"ur farbige Tabellenzellen}{}
links1 & rechts1\\ \hline
links2 & rechts2 \\ \hline
links3 & rechts3 \\ \hline
\zw{Programmierung}
links & rechts \\ \hline
\end{tabular}
\end{document}

More information you can get: array.ps, longtable.ps

Haben Sie noch weiterführende Fragen, so senden Sie bitte eine Email an latex-service.


Loading...