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.

The following is the source for a matrix I'm using in my document:

\documentclass{scrartcl}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}

\setcounter{MaxMatrixCols}{19}

\begin{document}
\[\begin{pmatrix}
1 & & & & & & & & & & & & & & & & & &\\
& 1 & & & & & & & & & & & & & & & & &\\
& & 1 & & & & & & & & & & & & & & & &\\
& & & 1 & & & & & & & & & & & & & & &\\
\beta_1 & \alpha & & & 1 & & & & & & & & & & & & & &\\
\beta_2 & \beta_1 & & & & 1 & & & & & & & & & & & & &\\
& \beta_2 & & & & & 1 & & & & & & & & & & & &\\
\beta_3 & & \alpha & & & & & 1 & & & & & & & & & &\\
\beta_4 & & \beta_3 & & & & & & 1 & & & & & & & & &\\
& & \beta_4 & & & & & & & 1 & & & & & & & & &\\
\beta_5 & & & \alpha & & & & & & & 1 & & & & & & & &\\
\beta_6 & & & \beta_5 & & & & & & & & 1 & & & & & & &\\
& & & \beta_6 & & & & & & & & & 1 & & & & & &\\
\beta_7 & \alpha & & & & & & & & & & & & 1 & & & & &\\
\beta_8 & \beta_7 & & & & & & & & & & & & & 1 & & & &\\
\beta_9 & & \beta_8 & & & & & & & & & & & & & 1 & & &\\
\beta_{10} & & \beta_9 & & & & & & & & & & & & & & 1 & &\\
\beta_{11} & & & \beta_{10} & & & & & & & & & & & & & & 1 &\\
& & & \beta_{11} & & & & & & & & & & & & & & & 1
\end{pmatrix}\]
\end{document}

The output looks very strange since the first four colums are wider than the last. But I guess I can't fix that, because otherwise the matrix would be too wide. Do you have any idea on what I could do to make the matrix look 'better'? Any suggestions are welcome. I have already thought of splitting the matrix up and only specifying the important 15x4 part.

Output

share|improve this question
    
[utf8] is not an option to fontenc, edited –  daleif Jul 4 '13 at 15:18
    
Maybe a sum of the important part + eye(19)? –  Mario S. E. Jul 4 '13 at 15:23

5 Answers 5

up vote 25 down vote accepted

According to my belief that no array using \multirow can't be improved by removing it, here's a simpler variation to percusse's answer:

\documentclass{scrartcl}
\usepackage[T1]{fontenc}
%\usepackage[latin1]{inputenc} % not necessary for the example
%\usepackage[english]{babel}
\usepackage{amsmath}

\begin{document}
\[
\left(\begin{array}{@{}c|c@{}}
\\
\mbox{\Huge$I$} & \makebox[12em]{\Huge$0$} \\
\\
\hline
\begin{matrix}
\beta_1 & \alpha \\
\beta_2 & \beta_1 \\
& \beta_2 \\
\beta_3 & & \alpha \\
\beta_4 & & \beta_3 \\
& & \beta_4 \\
\beta_5 & & & \alpha \\
\beta_6 & & & \beta_5 \\
& & & \beta_6 \\
\beta_7 & \alpha \\
\beta_8 & \beta_7 \\
\beta_9 & & \beta_8 \\
\beta_{10} & & \beta_9 \\
\beta_{11} & & & \beta_{10} \\
& & & \beta_{11} \\
\end{matrix} & \mbox{\Huge$I$}
\end{array}\right)
\]
\end{document}

enter image description here

share|improve this answer
1  
It would be nicer if the identity matrices had the dimensions: I_{4}, I_{15}. –  suvayu Jul 10 '13 at 12:26
    
@suvayu It's easy to add them and you're probably right. –  egreg Jul 10 '13 at 12:41
    
+1 for using block matrix visualization –  moose Jul 10 '13 at 17:16

You can remove the identity elements and replace with I.I forgot to put I_{4\times 4} and similarly 15 but you can add it directly.

Still too big but at least it's consistent. I would really go a low rank representation of that 4 column nonzero part and make it a variable.

\documentclass{scrartcl}
\usepackage{amsmath,multirow}
\setcounter{MaxMatrixCols}{19}

\begin{document}
\[\left(
\begin{array}{cccc|ccccccccccccccc}
\multicolumn{4}{c}{\multirow{4}[2]{*}{\Huge $I$}}&%
\multicolumn{15}{c}{\multirow{4}[2]{*}{\Huge$0$}}\\
&&&&&&&&&&&&&&&&&&\\
&&&&&&&&&&&&&&&&&&\\
&&&&&&&&&&&&&&&&&&\\\hline
\beta_1 & \alpha  &         &         &%
\multicolumn{15}{c}{\multirow{15}[2]{*}{\Huge$I$}}\\
\beta_2 & \beta_1 &         &         & & & & & & & & & & & & & & &\\
        & \beta_2 &         &         & & & & & & & & & & & & & & &\\
\beta_3 &         & \alpha  &         & & & & & & & & & & & & & &\\
\beta_4 &         & \beta_3 &         & & & & & & & & & & & & & &\\
        &         & \beta_4 &         & & & & & & & & & & & & & & &\\
\beta_5 &         &         & \alpha  & & & & & & & & & & & & & & &\\
\beta_6 &         &         & \beta_5 & & & & & & & & & & & & & & &\\
        &         &         & \beta_6 & & & & & & & & & & & & & & &\\
\beta_7 & \alpha  &         &         & & & & & & & & & & & & & & &\\
\beta_8 & \beta_7 &         &         & & & & & & & & & & & & & & &\\
\beta_9 &         & \beta_8 &         & & & & & & & & & & & & & & &\\
\beta_{10} &      & \beta_9 &         & & & & & & & & & & & & & & &\\
\beta_{11} &      &         & \beta_{10} & & & & & & & & & & & & & & &\\
        &         &         & \beta_{11} & & & & & & & & & & & & & & & 
\end{array}\right)\]
\end{document}

enter image description here

share|improve this answer
    
Please do what @egreg says. Next time I'll wait a few years to make sure that he doesn't write an answer. –  percusse Jul 6 '13 at 21:36

I'd tempted to write

\[
\left(
  \begin{array}{@{} c | c @{}}
    1_{4} & 0_{4} \\
    \hline
    A &  1_{15}
  \end{array}
\right)
\]

where ...

In general these very large matrices are very hard for the readers to understand and keep track of. If like in this case, it can easily be split into blocks, then that would help readability.

share|improve this answer

Although I agree with the answers which try to group in blocks the different parts of the matrix (such as Percusse's or egreg's answers), I'll provide an example which uses TikZ to draw a matrix more similar to the original one.

Using a matrix of math nodes, it is possible to ensure that each node (cell) has the same dimensions, and thus have all of them evenly spaced:

\usetikzlibrary{matrix}
\begin{tikzpicture}
\matrix[matrix of math nodes, column sep=0mm, 
   minimum width=4.5ex,  % Of each cell
   name=M, nodes in empty cells,
   left delimiter=(, right delimiter=)] {
  %% Exactly the same rows of the original code, copy&pasted here
  %% with \\ added in the last line
};
\end{tikzpicture}

Result

Now, being a tikz picture it is possible to draw lines which help to read the matrix. Each cell in the matrix is a tikz node which has a name automatically assigned, as M-y-x being y the row number and x the column number.

Update: debugging the figure

@Thomas noted in a comment that the line of 1s didn't look straight. I was unable to notice it, so I added the option nodes=draw to the matrix options. This was the result:

Debug

Now it is clearly visible that there are small horizontal gaps between some boxes, apparently due to the elements \beta_{10} and \beta_{11} beingh slightly larger than the minimum width used of 4.5ex. And, more important, not all cells have the same height, and this produces different distance between the rows. It is clearly noticeable that the first three rows have no vertical gaps between boxes, while the others have. (Incidentally I also discovered that two rows had the last cell missing).

So, enlarging a bit the minimum width and giving also a minimum height, the following result can be achieved:

Good

The above figure was produced by the following code (I grouped all node specific options into nodes keyword):

\begin{tikzpicture}
\matrix[matrix of math nodes, column sep=0mm, 
  nodes = {minimum height=3.6ex,
           minimum width=4.7ex, anchor=center, draw
           }, 
   name=M, nodes in empty cells,
   left delimiter=(, right delimiter=)] {
      %% The same rows of the original code, copy&pasted here and fixed
      %% with \\ added in the last line
   };
\end{tikzpicture}

Just to test your eyesight, there is the same figure without draw option:

Is this ok?

share|improve this answer
2  
It still looks bent though. Must be an optical illusion caused by the other entries. –  Thomas Jul 4 '13 at 17:31
    
@Thomas Answer updated. –  JLDiaz Jul 4 '13 at 22:12
    
Thanks - looks perfect now :) –  Thomas Jul 4 '13 at 22:20

Here's an attempt. First step, replace pmatrix with array so you can insert rules. Then we make the first few cols equal-spaced by putting in phantom elements equal in width to the widest thing appearing, beta_11.

Since the right-hand side of your matrix is essentially a rectangular block of zeroes above a unit submatrix, I refer to them as such and delineate them with horizontal/vertical rules. You can choose other symbols to refer to the unit matrix like a math-blackboard font 1 if you like, or use 1s in the top left and botom right corners and diagonal dots in between. Adjust the length of the right-hand part as desired.

You may want to mention in the accompanying text somewhere that the matrix is square and that (whatever symbol you choose) denotes a unit submatrix.

enter image description here

\[
\left(\begin{array}{lllll|c}
1 & \phantom{\beta_{11}} & \phantom{\beta_{11}} & \phantom{\beta_{11}} & \\
& 1 & & & \\ 
& & 1 & & & \mathbf{0} \\ 
& & & 1 & \\
   \beta_1 & \alpha  &         &            & 1 & \underline{\hspace{6em}}\\
   \beta_2 & \beta_1 &         &            & \\
           & \beta_2 &         &            & \\
   \beta_3 &         & \alpha  &            & \\
   \beta_4 &         & \beta_3 &            & \\
           &         & \beta_4 &            & \\
   \beta_5 &         &         & \alpha     & \\
   \beta_6 &         &         & \beta_5    & \\
           &         &         & \beta_6    & & \mathbf{1} \\
   \beta_7 &  \alpha &         &            & \\
   \beta_8 & \beta_7 &         &            & \\
   \beta_9 &         & \beta_8 &            & \\
\beta_{10} &         & \beta_9 &            & \\
\beta_{11} &         &         & \beta_{10} & \\
           &         &         & \beta_{11} & \\
\end{array}\right) 
\]
share|improve this answer
1  
Oops, "off by one" - the fifth column is redundant and should probably be deleted. –  Bristol Jul 4 '13 at 15:29

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.