4

How can something like this be done in MacTex:

enter image description here

12

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}

enter image description here

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}

enter image description here

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.