Kapitel 2

Tabellen mit LaTeX

2.1

Cells with equal width and height

\documentclass{article}
\usepackage{array}
\newcolumntype{C}[1]{@{}>{\rule[0.5\dimexpr-#1+1.2ex]{0pt}{#1}\hfil$}p{#1}<{$\hfil}@{}}
\begin{document}     
\Huge
$\begin{array}{|C{2cm} | C{2cm} |}\hline
  I_{r \times r} & 0 \\\hline
               0 & 0 \\\hline
\end{array} $ 
$\begin{array}{|C{2.5cm} | C{2.5cm} |}\hline
  I_{r \times r} & 0 \\\hline
               0 & 0 \\\hline
\end{array} $ 
\end{document}

2.1.1

\newcolumntype

\documentclass{article}
\usepackage{array,mathtools}

\newcolumntype{L}{>{$}l<{$}}
\newcolumntype{R}{>{$}r<{$}}
\def\V{\makebox[\widthof{=}]{$|$}}
\def\mc#1{\multicolumn{2}{@{}l@{}}{#1}}
\begin{document}

\noindent
\begin{tabular}{@{} p{5mm} R @{ } L L}
\mc{Label1...}                             \\
  & name1 ::= & choice11...  &comment11.   \\
  &         \V & choice12..   &comment12.. \\
  &         \V & chocie13.    &comment13...\\[10pt]
 %
\mc{Label2...}                             \\
  & name1 ::= & choice21...  &comment21.   \\
  &         \V & choice22..   &comment22.. \\
  &         \V & chocie23.    &comment23...\\
\end{tabular}

\end{document}

2.26

Columns with formatted numbers
\documentclass[12pt,a5paper]{article}
\usepackage{booktabs, siunitx, graphicx,caption}
\captionsetup[table]{position=above}
\def\RB#1{\rotatebox{90}{#1}}
\begin{document}
\noindent
\begin{minipage}{\textwidth}
\captionof{table}{Presentation of survival data for the whole sample (N = 13 298)}
\label{table:SurvivalAll}
\centering
\begin{tabular}{@{} l 
           S[table-format=5.0]
           S[table-format=4.0]
           S[table-format=3.0]
           S[table-format=3.0]
           S[table-format=4.0]
           S[table-format=2.2]
           S[table-format=2.2]
           S[table-format=1.2] @{}} \toprule
{\RB{Year}} & 
  {\RB{Risk Set}} & 
  {\RB{Graduated}}  & 
  {\RB{\shortstack{Academically\\Excluded}}} & 
  {\RB{Transferred}} & 
  {\RB{Censored}} & 
  {\RB{\shortstack{Hazard Ratio -\\Graduates}}} & 
  {\RB{\shortstack{Hazard Ratio -\\Academically\\ Excluded}}} & 
  {\RB{\shortstack{Hazard Ratio -\\Transferred}}} \\\midrule
1 & 13 298 & 0 & 725 & 583 & 1915 & 0.00 & 5.45 & 4.38  \\
2 & 10 075 & 0 & 474 & 176 & 1617 & 0.00 & 4.70 & 1.75 \\
3 & 7 808 & 1266 &  334 &   38 &    1030 &  16.21 & 4.28 &  0.49 \\
4 & 5 139 & 2782 &  147 &   2 & 455 &   54.14 & 2.86 &  0.04 \\
5 & 1 754 & 1135 &  76 &    2 & 205&    64.71 & 4.33 &  0.11 \\
6 & 336 &   235 &   17 &    0 & 39 &    69.94 & 5.06 &  0.00 \\ 
7 & 45 &    28 &    7 & 0 & 5 & 62.22 & 15.56 & 0.00 \\
8 & 5 & 3 & 0 & 0 & 2   & 60.00 &   0.00 &  0.00 \\
\bottomrule
\end{tabular}
\end{minipage}
\end{document}

Zurück zur Hauptseite/Back to main page
Copyright $Id: chapter02.html 6 2022-12-28 17:12:39Z voss $