%% Use A4 page size
\documentclass[a4paper,12pt]{amsart}

%% Smaller margins
\usepackage{fullpage}

%% Use also various symbols from the AMS
\usepackage{amsmath,amssymb}

%% A font with slightly different calligraphic letters
\usepackage{mathrsfs}

%% The basic package to include graphics
\usepackage{graphicx}

%% For certain tables
\usepackage{xtab}

%% For listings
\usepackage{listings}

%% For (commutative) diagrams
\usepackage{tikz-cd}
\tikzset{commutative diagrams/arrow style=math font}

%% The colorlinks option gives colored links instead of boxes around
%% links for equation numbers and other references
%% This can be a problem for color-blind readers
\usepackage[colorlinks]{hyperref}

%% The usual theorems
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[section]
\newtheorem*{theorem*}{Theorem}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}

%% Style for remarks
\theoremstyle{remark}
\newtheorem{remark}{Remark}

%% Style for definitions
\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}

%% Define a new command to typeset SL as a function
\DeclareMathOperator{\SL}{SL}

%% Some other operators
\DeclareMathOperator{\GL}{GL}
\DeclareMathOperator{\St}{St}

%% An operator where the subscripts/superscripts appear under/over the
%% symbol
\DeclareMathOperator*{\expect}{\mathbf{E}}

%% Allow to put some text over an arrow: this is a command with one
%% argument
\newcommand{\fleche}[1]{\stackrel{{#1}}{\longrightarrow}}

%% Use the AMS versions of the "less than or equal to" and "larger
%% than or equal to" signs
\renewcommand{\leq}{\leqslant}
\renewcommand{\geq}{\geqslant}

%% A command "boldmath" to type bold mathematical formulas in such a
%% way that small letters remain slanted instead of being straight
\newcommand{\bm}[1]{\text{\boldmath${#1}$}}

%% Modulo with parentheses but smaller horizontal space than \pmod
\newcommand{\mods}[1]{\,(\mathrm{mod}\,{#1})}

%% The basic number sets in the bold style
\newcommand{\C}{\mathbf{C}}
\newcommand{\R}{\mathbf{R}}
\newcommand{\F}{\mathbf{F}}
\newcommand{\Q}{\mathbf{Q}}
\newcommand{\Z}{\mathbf{Z}}
\newcommand{\Pp}{\mathbf{P}}

%% A symbol for disjoint union; mathrel indicates that the spacing
%% around the symbol should as for other relation symbols.
\newcommand{\dunion}{\mathrel{\sqcup}}

%% Prefer the varepsilon for epsilon, and give it a shorter name
\newcommand{\eps}{\varepsilon}

%% Begin the text
\begin{document}

%% Title
\title{File for 25.10.2023}

%% Author
\author{E. Kowalski}
%% Physical address
\address{ETH Zürich, Rämistrasse 101, 8092 Zürich, Switzerland}
%% Email address
\email{kowalski@math.ethz.ch}

\begin{abstract}
  LaTeX for tables, diagrams, listings.
\end{abstract}

\maketitle

%% Display a table of contents
%% This can also be used in articles when they are a bit long
\tableofcontents

\section{Tables}

A basic table using \verb|tabular|.

\bigskip

\begin{center}
\begin{tabular}{|c|c||c|c|c|c|}
\hline
$n$ & Samples & Average of $t_n$ & Average of $\tau_n$ & 
Ratio & Average of $t_n/\tau_n$\\\hline
$10$  & $100000$ &
$29.25832$ & $38.45245$ & $1.314240$&
$1.428859$
\\\hline
$15$ &$100000$ &
$49.82383$ & $62.78493$ & $1.260139$ &
$1.350101$
\\\hline
$20$&$100000$ &
$71.91587$ & $88.37135$ & $1.228816$&
$1.302885$
\\\hline
 $25$ & $70000$ &  $95.11283$ & $115.36589$ &
 $1.212937$ & $1.277969$\\\hline
 $30$ & $70000$ & $119.9001$ & $143.3866$&
 $1.195884$ & $1.253686$\\\hline
$40$ & $70000$ & $171.1540$ & $201.5358$ &
$1.177512$ & $1.226495$\\\hline
$50$ & $35000$ & $225.1010$ & $263.0281$ &
$1.168489$ & $1.211726$
\\\hline
$75$ & $30000$ & $367.6880$ & $422.5577$ &
$1.149229$ & $1.184520$ \\\hline
$100$ & $30000$ & $519.6102$ & $590.7413$ &
                                            $1.136893$ & $1.167134$ \\\hline
  $75$ & $30000$ & $367.6880$ & $422.5577$ &
$1.149229$ & $1.184520$ \\\hline
$100$ & $30000$ & $519.6102$ & $590.7413$ &
$1.136893$ & $1.167134$ \\\hline
  $75$ & $30000$ & $367.6880$ & $422.5577$ &
$1.149229$ & $1.184520$ \\\hline
$100$ & $30000$ & $519.6102$ & $590.7413$ &
$1.136893$ & $1.167134$ \\\hline
  $75$ & $30000$ & $367.6880$ & $422.5577$ &
$1.149229$ & $1.184520$ \\\hline
$100$ & $30000$ & $519.6102$ & $590.7413$ &
$1.136893$ & $1.167134$ \\\hline
\end{tabular}
\end{center}

\bigskip

Various packages exist for more sophisticated tables, including table
spanning over a page break.
Here an example with \verb|xtab|.

\bigskip

\begin{center}
\bottomcaption{Character table of $\GL_2(\F_p)$}
\tablehead{
\hline
& 
$\begin{pmatrix}
a & 0 \\
0 & a
\end{pmatrix}$
&
$\begin{pmatrix}
a&1\\
0 &a
\end{pmatrix}$
&
$\begin{pmatrix}
a&0\\
0 &b
\end{pmatrix}$%%, $b\not=a$
&
$\begin{pmatrix}
a&b\\
\eps b &a
\end{pmatrix}$%%, $b\not=0$
\\
\hline
}
{\small
\renewcommand{\arraystretch}{1.3}
\begin{xtabular}{c|c|c|c|c}
$\chi\circ\det$&
$\chi(a^2)$&
$\chi(a^2)$&
$\chi(ab)$&
$\chi(a^2-\eps b^2)$\\
\hline
$\pi(\chi_1,\chi_2)$ &
$(p+1)\chi_1(a)\chi_2(a)$&
$\chi_1(a)\chi_2(a)$&
$\begin{array}{c}\chi_1(a)\chi_2(b)+\\
\chi_2(b)\chi_1(a)
\end{array}$
&
$0$
\\
\hline
$\St(\chi)$ &
$p\chi(a^2)$&
$0$&
$\chi(ab)$&
$-\chi(a^2-\eps b^2)$
\\
\hline
$R(\phi)$&
$(p-1)\phi(a)$&
$-\phi(a)$&
$0$&
$\begin{array}{c}
-(\phi(a+b\sqrt{\eps})+
\\
\phi(a-b\sqrt{\eps}))\end{array}$\\
\hline
\end{xtabular}
}\end{center}


\section{Listings}

The package \verb|listings| gives many options to include computer
program listings.

\lstset{basicstyle=\small\ttfamily}
\begin{lstlisting}
A<T>:=PolynomialRing(RationalField()); 
E8:=GroupOfLieType("E8",RationalField()); 
gen:=AlgebraicGenerators(E8); 
rho:=AdjointRepresentation(E8); 
g:=Identity(E8); for i in gen do g:=g*i ; end for;  
m:=rho(g); 
pol:=CharacteristicPolynomial(m) div (T-1)^8; 
\end{lstlisting}

\section{(Commutative) diagrams}

The simplest diagrams can be done using basic LaTeX, but look ugly:
\begin{gather*}
  \begin{aligned}
    1  & \to & A   & \to  & B & \fleche{f} & C &\to & 1\\
    \downarrow &     & \downarrow &   & \downarrow &     \\
    1 & \to  & A' & \to   & B' & \to & \ C' &\to & 1.
  \end{aligned}
\end{gather*}

Specialized packages give much better results, but are more complicated
to use. Here are examples with \verb|tikz-cd|:

$$
\begin{tikzcd}
  1\arrow[r] & A\arrow[d,"f"]\arrow[r] & B \arrow[r] & C\arrow[d]\arrow[r]& 0
  \\
  1\arrow[r]\arrow[u] & A'\arrow[rr] &  & C'\arrow[r]& 0
\end{tikzcd}
$$
or
$$
\begin{tikzcd}
  \Pp^n_{S'} \arrow[r,"f'"] \arrow[d,"s"]
  & S'\arrow[d,"s"]\arrow[dr,"s'"]&\\
  \Pp^n_{S}\times_S M^{m+1,n+1}_S \arrow[r]\arrow[rr,bend right,"f"
  description] &M^{m+1,n+1}_S\arrow[r]&S.
\end{tikzcd}
$$

\bigskip

To give the definition of a function:
$$
f \  \left\{
  %% The ccc indicates that each of the three columns is individually
  %% centered 
  \begin{array}{ccc}
    \R^2 & \to & \Z\\
    (x,y) &\mapsto & \lfloor xy\rfloor
  \end{array}
\right.
$$

Compare with:
$$
\begin{cases}
  \R^2 \to \Z\\
  (x,y)\mapsto \lfloor xy\rfloor
\end{cases}
$$

\end{document}
