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 I re-produce the following figure using LaTeX? (Drawn in excel, using borders).

enter image description here

share|improve this question
    
...the fonts look more like TeX's Computer Modern than what Excel would provide. –  Werner Oct 30 '11 at 18:52
add comment

1 Answer

up vote 11 down vote accepted

You can either use an array in math mode:

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}
\[
  \begin{array}{r|l}
    \text{Independent Variable} & \text{Dependent Variable} \\ \hline
    x_1 & y_1 \\
    x_2 & y_2 \\
    \vdots & \vdots \\
    x_n & y_n
  \end{array}
\]
\end{document}

enter image description here

or you could do something similar using a text mode tabular. amsmath provides \text{<stuff>} that typesets <stuff> in text mode within math mode. If you're interested in centering the \vdots with respect to the other elements in the column, you could use the calc package which provides \widthof{<stuff>}. Here's a brief example:

enter image description here

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\usepackage{calc}% http://ctan.org/pkg/calc
\begin{document}
\[
  \begin{array}{r|l}
    \text{Independent Variable} & \text{Dependent Variable} \\ \hline
    x_1 & y_1 \\
    x_2 & y_2 \\
    \makebox[\widthof{$x_2$}][c]{$\vdots$} & \makebox[\widthof{$y_2$}][c]{$\vdots$} \\
    x_n & y_n
  \end{array}
\]
\end{document}

The use of \vdots provides a slightly different view to yours. However, if may be accomplished using three identical rows of \cdot & \cdot \\ replacing the \vdots & \vdots \\:

enter image description here

share|improve this answer
1  
IMHO the compact version with vdots is to be preferred. Also to center them a bit $\,\vdots\,\,$, what do you think? –  Yiannis Lazarides Oct 30 '11 at 3:18
    
@YiannisLazarides: Thanks, I included something to this effect in my revised answer. I agree on the use of \vdots as opposed to three \cdots. –  Werner Oct 30 '11 at 3:27
add comment

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.