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.

(From the notation used in course notes for Stanford CS229 available online.) I'm trying to typeset the following matrices made up of row or column vectors:

enter image description here

Any ideas?

share|improve this question
    
Thanks for the cleanup! –  zellyn Mar 8 '11 at 6:46
add comment

2 Answers

up vote 3 down vote accepted

You can use rules to create the vertical and horizontal bars and then just put them into your array directy.

\documentclass{article}
\usepackage{array}
\begin{document}
\newcommand*{\vertbar}{\rule[1ex]{0.5pt}{2.5ex}}
\newcommand*{\horzbar}{\rule[.5ex]{2.5ex}{0.5pt}}

\[
A = 
\left[
  \begin{array}{cccc}
    \vertbar & \vertbar & & \vertbar\\
    a_{1} & a_{2} & \ldots & a_{n} \\
    \vertbar & \vertbar & & \vertbar 
  \end{array}
\right]
\]
\setlength{\extrarowheight}{1ex}
\[
A =
\left[
  \begin{array}{ccc}
    \horzbar & a^{T}_{1} & \horzbar\\
    \horzbar & a^{T}_{2} & \horzbar\\
    & \vdots & \\
    \horzbar & a^{T}_{n} & \horzbar
  \end{array}
\right]
\]

\end{document}

result of code

share|improve this answer
add comment
\documentclass{article}
\usepackage{array}
\begin{document}

\[
A = 
\left[
  \begin{array}{cccc}
    \vrule & \vrule & & \vrule\\
    a_{1} & a_{2} & \ldots & a_{n} \\
    \vrule & \vrule & & \vrule 
  \end{array}
\right]
\]
\setlength{\extrarowheight}{1ex}
\[
A =
\left[
  \begin{tabular}{c>{$}c<{$}c}
    --- & a^{T}_{1} & ---\\
    --- & a^{T}_{2} & ---\\
    & \vdots & \\
    --- & a^{T}_{n} & ---
  \end{tabular}
\right]
\]

\end{document}

enter image description here

share|improve this answer
    
When I used --- in math mode, I got three minuses. I had to use \text{---} to make it work. But it seems to be working for you... any ideas why? –  zellyn Mar 8 '11 at 19:16
    
no, in math it is always ---. I used a tabular which is by default in textmode ... –  Herbert Mar 8 '11 at 19:20
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.