Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How can something like this be done in MacTex:

enter image description here

share|improve this question

1 Answer 1

up vote 13 down vote accepted

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

share|improve this answer
    
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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