# Table of Values

How can something like this be done in MacTex:

-
add comment

## 1 Answer

One possibility using an array; numbering for the first column is done automatically:

\documentclass{article}
\usepackage{array}

\newcounter{myrow}
\begin{document}

$\begin{array}{>{\stepcounter{myrow}\themyrow}c|*{5}{c}} \multicolumn{1}{c|}{} & 1 & 2 & 3 & 4 & 5 \\ \hline & 0 & 1 & 0 & 1 & 0 \\ & 1 & 1 & 0 & 1 & 0 \\ & 0 & 1 & 1 & 1 & 0 \\ & 1 & 0 & 0 & 1 & 0 \\ & 0 & 1 & 1 & 1 & 0 \\ \end{array}$

\end{document}


Or:

\documentclass{article}
\usepackage{array}

\newcounter{myrow}
\begin{document}

$\begin{array}{c|*{5}{c}} \multicolumn{1}{c|}{} & 1 & 2 & 3 & \cdots & n \\ \hline 1 & 0 & 1 & 0 & \cdots & \\ 2 & 1 & 1 & 0 & \cdots & \\ 3 & 0 & 1 & 1 & \cdots & \\ \vdots & \vdots & \vdots & \vdots & \ddots & \\ n & & & & & \\ \end{array}$

\end{document}


-
Fantastic! Thank you so much, Gonzalo Medina. –  Trancot Jul 22 at 17:19
@Trancot You're welcome! Don't forget that you can accept the answer if you consider it solved your problem ;-) –  Gonzalo Medina Jul 22 at 18:46
add comment