5

I have matrices with dense expressions in them and I'd like to loosen the matrix brackets a little. I'd like to be able to control the horizontal distance from bracket to first letter (both sides) and the vertical distance between the expressions. Vertically I'd like to only change the size below a row, unlike arraystretch does.

Consitency thereby is very important, so local solutions are no good for me. I tried arraystretch and % \setlength{\extrarowheight}{10pt}, but those add extra space upon and below each line. I'd like an output similar to the following (preferably tunable), for all matricies in the document.

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\horizontaldistance{2pt}
\vertical_distance{5pt}

\[
\begin{bmatrix}
  \horizontaldistance s'^{\mathrm{T}} \horizontaldistance    \\[vertical_distance]
  \horizontaldistance I_{p\times p} \horizontaldistance
\end{bmatrix}
\]

\end{document}

My goal would be, that I do not have to write the distances explicitly into the matrix, but that ALL bmarix instances at once have the same distances!

  • 2
    off-topic: maybe you want to use \mathrm{T} instead of \text. – Sigur Sep 5 '15 at 21:22
  • I'm afraid your write-up isn't entirely clear. What typographic aspect are you trying to fine-tune: The space to the left and write of the terms, the vertical distance between the terms, or both? If not 10em distance, which distance? Please advise. – Mico Sep 5 '15 at 21:24
  • Are you not happy with the size \left and \right produce? Set \fboxrule=0pt then use \left[\fbox{\begin{array}...\end{array}}\right] and play with \fboxsep. – John Kormylo Sep 5 '15 at 23:02
  • I don't fully understand your answer: would that mean to replace every bmatrix with \left[\fbox{\begin{array}.. ? Then I'd loose all the neat properties of the bmatrix. And yet the vertical problem is till there?! – mike Sep 6 '15 at 7:20
  • For the horizontal spacing, you could try \arraycolsep. For the vertical spacing you could add height to all but the first row using \vphantom. – JPi Sep 6 '15 at 8:46
1

REVISED SOLUTION (for global automation):

Here one employs TABstacks in lieu of the bmatrix environment.

Here one controls global settings of \setstackgap{L}{} for vertical spacing of baselines, \setstacktabbedgap{} for horizontal spacing inside the matrices, and \lrgap for the spacing at the left and right extremities of the vectors/matrices.

\documentclass{article}
\usepackage{tabstackengine}
\stackMath
\setstackgap{L}{24pt}
\setstacktabbedgap{4pt}
\def\lrgap{\kern6pt}
\def\xbracketVectorstack#1{\left[\lrgap\Vectorstack{#1}\lrgap\right]}
\def\xbracketMatrixstack#1{\left[\lrgap\tabbedCenterstack{#1}\lrgap\right]}
\begin{document}
\[
\xbracketVectorstack{
  s'^{\mathrm{T}}  \\
  I_{p\times p}   
}=
\xbracketMatrixstack{
  A & B \\
  C & D   
}
\xbracketVectorstack{
  s'^{\mathrm{T}}  \\
  I_{p\times p}   
}
\]
\end{document}

enter image description here

ORIGINAL SOLUTION

Attempting to achieve the goal with the minimal changes to the OP's code.

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\def\horizontaldistance{\kern2pt}
\def\verticaldistance{5pt}

\[
\begin{bmatrix}
  \horizontaldistance s'^{\mathrm{T}} \horizontaldistance    \\[\verticaldistance]
  \horizontaldistance I_{p\times p}   \horizontaldistance
\end{bmatrix}
\]

\end{document}
  • Although I hoped there would be a simple hack for the bmatrix environment, this seems to be a pretty good subsitute. – mike Sep 8 '15 at 17:48
2

Well I'm not sure exactly what you're asking for but I read it as you wanting a more sensible way to control the width of your matrix braces. The approach I chose uses makeboxes. The downside is you need to re-enter math mode as it seems makeboxes take you out of it.

Here's the code:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\newcommand*{\horizontaldista}[3]{\makebox[#1][#2]{#3}}
\newcommand*{\horizontaldistb}[2]{\makebox[#1][c]{#2}}
\newcommand*{\fixeddist}[1]{\makebox[10em][c]{#1}}
\[
\begin{bmatrix}
    \makebox[4em][c]{$s'^{\mathrm{T}}$} \\[10ex]
    \horizontaldista{4em}{c}{$I_{p\times p}$}\\
\end{bmatrix}
\]
\vspace*{10ex}
\[
\begin{bmatrix}
    \fixeddist{$s'^{\mathrm{T}}$}\\[10ex]

    \fixeddist{$I_{p\times p}$}\\[10ex]

    \horizontaldistb{4em}{$I_{p\times p}$}
\end{bmatrix}
\]
\end{document}

I defined a number of new commands and demonstrated their usage. Depending on what trade-off you want between local and global tweaking one may be more appropriate to your purposes.

  • Thanks for the write-up, but the whole point would be, that I do not have to apply distances on each matrix. I need something global for each instance of a bmatrix, such that the spacing is consistent over a document, without having cluttered each equation. – mike Sep 7 '15 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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