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.

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
add comment

marked as duplicate by Andrew Stacey, 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.

2 Answers

up vote 5 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
1  
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
add comment

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
4  
@barbarabeeton This would be a nice addition for amsmath, wouldn't it? –  egreg Nov 3 '11 at 9:36
add comment

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