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.

I am trying to reproduce the following matrix

enter image description here

I tried with this:

\begin{equation*}
\begin{bmatrix}[ccc:c]
a_{11} & \cdots & a_{1n} & b_1 \\
\vdots &  & \vdots & \vdots \\
a_{n1} & \cdots & a_{nn} & b_n
\end{bmatrix}\sim
\begin{bmatrix}[ccc|ccc:c]
a'_{11} & & 0 & & & & b'_1 \\
 & \ddots & & & \mbox{\Huge 0} & & \vdots \\
 0 & & a'_{kk} & & & & \vdots \\ \cline{1-6}
  & & & a'_{kn} & & & \vdots \\
  & \mbox{\Huge 0} & & & \ddots & & \vdots \\
  & & & & & & b'_k
\end{bmatrix}
\end{equation*}

but I get this:

enter image description here

Why is the left side of \cline going 'out of matrix bounds'?

My preamble looks like this:

\documentclass[a4paper,12pt,twoside]{article}


\usepackage{amsmath,amssymb,amsthm,amssymb}
\usepackage{mathtools}
\usepackage{bbm}
\usepackage{graphicx}
\usepackage{floatrow}
\usepackage{float}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[croatian]{babel}
\usepackage{ucs}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{enumerate}
\usepackage{fullpage}
\usepackage[dvipdfm,colorlinks=true,pdfstartview=FitB,bookmarks=false,urlcolor=blue,citecolor=LimeGreen,linkcolor=BrickRed,bookmarksnumbered]{hyperref}
\usepackage{url}
%\usepackage[all]{hypcap}
\usepackage{tgtermes}
\usepackage{newtxmath}
\usepackage[usenames,dvipsnames,svgnames]{xcolor}
\usepackage{titlesec}
\usepackage{wrapfig}
\usepackage{arydshln,leftidx}
\usepackage{multirow}
\usepackage{bigdelim}
%\usepackage{subcaption}
%\usepackage[labelformat=empty]{caption}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usetikzlibrary{decorations.shapes}

% Table float box with bottom caption, box width adjusted to content
\newfloatcommand{capbtabbox}{table}[][\FBwidth]

\makeatletter
  \renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
    \hskip -\arraycolsep
    \let\@ifnextchar\new@ifnextchar
  \array{#1}}
\makeatother

\newtheorem{crteorem}{Teorem}
\newtheorem{podt}{Podteorem}
\newtheorem{definicija}{Definicija}
\newtheorem{korolar}{Korolar}
\newtheorem{lema}{Lema}

\titleformat*{\section}{\normalfont\Large\bfseries\color{RoyalBlue}}
\titleformat*{\subsection}{\normalfont\large\bfseries\color{PineGreen}}
\titleformat*{\subsubsection}{\normalfont\normalsize\bfseries\color{RedViolet}}


\renewcommand{\d}[2]{\frac{d #1}{d #2}} % derivacije
\newcommand{\dd}[2]{\frac{d^2 #1}{d #2^2}} % druga derivacija
\newcommand{\pd}[2]{\frac{\partial #1}{\partial #2}} 
% parcijalna derivacija
\newcommand{\pdd}[2]{\frac{\partial^2 #1}{\partial #2^2}} 
% druga parcijalna derivacija
\newcommand{\abs}[1]{\left| #1 \right|} % za apsolutnu vrijednost

\makeatletter
\def\Ddots{\mathinner{\mkern1mu\raise\p@
\vbox{\kern7\p@\hbox{.}}\mkern2mu
\raise4\p@\hbox{.}\mkern2mu\raise7\p@\hbox{.}\mkern1mu}}
\makeatother

\urlstyle{rm}

\numberwithin{equation}{section}
\thispagestyle{headings}
\pagenumbering{roman}

I tried by loading minimum amount of packages (like math ones), but in that case tex won't recognise the [ccc|ccc:c] part :\

Also, the right upper side of the second matrix is kinda uneven :S

share|improve this question

1 Answer 1

up vote 5 down vote accepted

Replace bmatrix with an array. Here is a MWE:

\documentclass[a4paper,12pt,twoside]{article}

\usepackage{amsmath,amssymb,amsthm,amssymb}
\usepackage{arydshln}

\begin{document}

\begin{equation*}
\left[\begin{array}{ccc:c}
a_{11} & \cdots & a_{1n} & b_1 \\
\vdots &  & \vdots & \vdots \\
a_{n1} & \cdots & a_{nn} & b_n
\end{array}\right]
\sim
\left[\begin{array}{ccc|ccc:c}
a'_{11} & & 0 & & & & b'_1 \\
 & \ddots & & & \mbox{\Huge 0} & & \vdots \\
 0 & & a'_{kk} & & & & \vdots \\ \cline{1-6}
  & & & a'_{kn} & & & \vdots \\
  & \mbox{\Huge 0} & & & \ddots & & \vdots \\
  & & & & & & b'_k
\end{array}\right]
\end{equation*}

\end{document}

The output:
The output

If more space is needed, toy a bit with the array formats. For example, try putting @{\hspace{1cm}|\hspace{3mm}} instead of | and you'll get the idea.

As for the packages, you need arydshln to use : for vertical dashed lines in tabular environments (i.e., in the arrays above).

share|improve this answer
    
Thank you :) That did the trick :) –  dingo_d Jul 11 '13 at 14:49

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.