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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
What's the best way make an “augmented” coefficient matrix?

I am trying to make a vertical line in a matrix in LaTeXiT. I have read that it should be possible using the following:

\begin{bmatrix}{cccc|c}
1 & 0 & 3 & -1 & 0 \\
0 & 1 & 1 & -1 & 0 \\
0 & 0 & 0 & 0 & 0 \\
\end{bmatrix}

But when doing so, this is my output:

enter image description here

share|improve this question

marked as duplicate by Loop Space, Torbjørn T., Joseph Wright Nov 30 '11 at 12:46

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 12 down vote accepted

The bmatrix environment does not provide this facility (see section 4.1 of the amsmath package documentation). You can use the array environment instead.

\[
\left[
\begin{array}{cccc|c}
1 & 0 & 3 & -1 & 0 \\
0 & 1 & 1 & -1 & 0 \\
0 & 0 & 0 & 0 & 0 \\
\end{array}
\right]
\]
share|improve this answer
2  
Possibly adding @{} at the sides: @{}cccc|c@{}, so as to give a similar result to bmatrix. – egreg Nov 3 '11 at 9:33
    
Thank you very much. The output of this is just like a bmatrix. – SimonBS Nov 3 '11 at 9:43
    
@egreg: Could you explain how the @{} works? I see that it has the effect of reducing the whitespace between the [ and ] and the matrix contents. – user001 Mar 13 '12 at 17:30
    
With @{...} you tell LaTeX to put ... in place of the default intercolumn space, which is applied also at the start and end of the tabular. – egreg Mar 13 '12 at 17:37

That won't work with the matrix environment from amsmath, however Stefan Kottwitz wrote about a workaround for this on his blog.

\documentclass{article}
\usepackage{amsmath}
\makeatletter
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
  \hskip -\arraycolsep
  \let\@ifnextchar\new@ifnextchar
  \array{#1}}
\makeatother
\begin{document}
\begin{equation}
  \begin{bmatrix}[cccc|c]
   1 & 0 & 3 & -1 & 0 \\
    0 & 1 & 1 & -1 & 0 \\
    0 & 0 & 0 & 0 & 0 \\
  \end{bmatrix}
\end{equation}
\end{document}

enter image description here

share|improve this answer
9  
@barbarabeeton This would be a nice addition for amsmath, wouldn't it? – egreg Nov 3 '11 at 9:36
    
This answer should be accepted, is not it? – Gudson Chou Jun 21 '15 at 5:00
    
@Chou It's up to the person asking the question to decide which answer was most helpful for him or her. It's not always the highest voted answer that is accepted. – Torbjørn T. Jun 21 '15 at 7:37
    
I know the rules here. You may take my words as an indirect praise; for your work helped me. :) By the way, I was not aware of the number of votes til your comment coming out. – Gudson Chou Jun 21 '15 at 9:30

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