This is my minimal working example.
\documentclass[12pt,a4paper]{mwrep}
%\usepackage{amsfonts}
\usepackage{amsmath}
%\renewcommand\baselinestretch{1.5}
\begin{document}
\chapter{Example}
\begin{equation}
P=
\begin{bmatrix} p_{11} & p_{12} & \cdots & p_{1r} \\
p_{21} & p_{22} & \cdots & p_{2r} \\
\vdots & \vdots & \ddots & \vdots \\
p_{r1} & p_{r2} & \cdots & p_{rr}
\end{bmatrix}
\end{equation}
\end{document}
This is view of the matrix when lines 2 and 4 are left commended (200%)
This is what you get when you uncomment them (200%)
As you can see the brackets are thinner and size is different. I don't mind it. But I don't like those gaps in brackets. How can I get rid of them?
How can I make bmatrix
behave like lines 2 and 4 were left commented and the rest of document like they were uncommented?
Best Answer
Whilst I agree with the comments that this is most likely due to the viewer, it is nonetheless irritating. I believe that when printed this effect is not seen, but since TeX is used quite a lot nowadays for presentations then how it looks in a particular viewer is becoming more important than it was. So despite it likely to be an issue with the viewer, it is still an issue worth solving.
The problem is that TeX is building the delimiters out of pieces and the viewer is rendering these pieces in a non-optimal manner and showing the spaces between them. (Unfortunately, I also dislike it when it does the opposite and overlaps the pieces as I can see the overlaps as extra thick pieces!).
A simple way to solve it is to use a font that has proper scalable delimiters, as mentioned in the accepted answer to Vertical vectors in angle brackets.
Another way of solving it would be to draw the delimiters as a single entity, rather than build them piecemeal. We had a question about replacing the AMS matrices with TikZ matrices: Obstacles to simulating an amsmath matrix by a TiKZ matrix of math nodes. In answering that question, I figured out a drop-in replacement for the standard AMS matrix environments using TikZ matrices instead. However, for the delimiters then it uses the standard delimiters so doesn't solve this problem.
But it wasn't too difficult to modify the code there to make it so that it draws the delimiters using TikZ code. By using my
calligraphy
package, I could even get nice tapering on the brace and parenthesis versions. At time of writing, the calligraphy package is not on CTAN, but you can get it from http://bazaar.launchpad.net/~tex-sx/tex-sx/development/files (you also need thespath.dtx
file).I'll put the code in a moment, first I want to show the result. The following is a matrix of matrices. Each row is a particular type (
bmatrix
,pmatrix
, etc). The first in each row has TikZ draw the delimiters. The second has TikZ use "standard" delimiters. The third is the corresponding matrix command from the AMS packages.The code follows.
The change from the code as in Obstacles to simulating an amsmath matrix by a TiKZ matrix of math nodes is that after rendering the matrix, we draw a line down each side. But we decorate the path according to the type of delimiter chosen. If we didn't use the calligraphy package, we'd have to change some of the choices of decorations in the list near the beginning:
calligraphic brace
could be replaced bybrace
andcalligraphic curved parenthesis
bybent
.One advantage of this approach is that it allows for more variation in the delimiters. We can define new decorations, and can style the paths in a variety of different ways.