5

I'm using the bmatrix environment with fractional entries. My problem is that the fractions extend beyond the "edge" created by the brackets. I know there are other environments that could be used. How might one correct this? Also, I want my fractions written in the form below, not, for example, 1/2. Here is my code:

\documentclass{article}
\usepackage{amsmath, amssymb, mathtools, fouriernc}
\newcommand{\vecd}[1]{\mathbf{#1}}
\begin{document}
 \[
 \vecd{x}^{(k+1)} = \begin{bmatrix*}[r] 0 & \tfrac{1}{4} & -\tfrac{1}{4} \\[3pt] \tfrac{1}{3} & 0 & -\tfrac{1}{3} \\[3pt] -\tfrac{1}{5} & -\tfrac{1}{5} & 0  \end{bmatrix*} \vecd{x}^{(k)} + \begin{bmatrix*}[r] 4 \\ -1 \\ 1 \end{bmatrix*}
  \]
\end{document}
DJJerome
  • 4,056
  • 2
    ! Undefined control sequence. l.5 \vecd and ! LaTeX Error: Environment bmatrix* undefined. Please correct your example – David Carlisle Oct 23 '13 at 13:54
  • 2
    It is compiling without errors here. I can't see the 'beyond delimiters' problem, though. Image – Pedro Oct 23 '13 at 14:05
  • The error is fixed now. I apologize for it. – DJJerome Oct 23 '13 at 15:01
  • Readers, an edited question reveals the problem arises as an interaction with the fouriernc package. Perhaps Djjerome can edit his title or question to reflect that point. – Steven B. Segletes Oct 23 '13 at 17:22
  • IMHO even the way how it looks is fine. In general, I don't see any need for delimiters to cover the whole thing they "delimit", be it a matrix, fraction, complicated exponent or whatever. – yo' Oct 23 '13 at 17:31
  • Point taken. I was more interested in why it occurs and how it might be fixed should there be the want to do so. I'm sure others could comment on the typographical correctness of it. – DJJerome Oct 23 '13 at 19:15

2 Answers2

4

For fouriernc a lower value of \delimitershortfall than the default 5pt seems necessary:

\documentclass{article}
\usepackage{amsmath, amssymb, mathtools, fouriernc}
\newcommand{\vecd}[1]{\mathbf{#1}}

\delimitershortfall=3pt

\begin{document}
\[
\vecd{x}^{(k+1)} = 
  \begin{bmatrix*}[r]
  0 & \tfrac{1}{4} & -\tfrac{1}{4} \\[3pt]
  \tfrac{1}{3} & 0 & -\tfrac{1}{3} \\[3pt]
  -\tfrac{1}{5} & -\tfrac{1}{5} & 0
  \end{bmatrix*}
  \vecd{x}^{(k)} 
+ \begin{bmatrix*}[r] 4 \\ -1 \\ 1 \end{bmatrix*}
+ \begin{bmatrix*}[r] 4 \\ -1 \end{bmatrix*}
\]
\end{document}

I apologize for the nonsense math: I just wanted to show the effect.

enter image description here

egreg
  • 1,121,712
3

As you note, the problem is a bad interaction with one of your packages. To manually overcome it, I define \mystrut which is a rule that sinks low enough and rises high enough so that adding it to a top row entry and to a bottom row entry, suitably grows the height of the brackets.

However, I also give this solution as an alternative approach, if you wish to control the vertical and horizontal spacing between matrix entries, which may be of use when displaying \textstyle fractions, as you do.

After giving your original solution, and the modified solution with the strut fix, I then give a solution that uses my under-construction tabstackengine.sty package, currently posted at Writing a table with equally spaced columns, based on the widest column

\documentclass{article}
\usepackage{amsmath, amssymb, mathtools, fouriernc}
\usepackage{tabstackengine}
\newcommand{\vecd}[1]{\mathbf{#1}}
\newcommand\mystrut{\rule[-1.5ex]{0ex}{4ex}}
\begin{document}
ORIGINAL
 \[
 \vecd{x}^{(k+1)} = \begin{bmatrix*}[r] 0 & \tfrac{1}{4} & -\tfrac{1}{4} \\[3pt] \tfrac{1}{3} & 0 & -\tfrac{1}{3} \\[3pt] -\tfrac{1}{5} & -\tfrac{1}{5} & 0  \end{bmatrix*} \vecd{x}^{(k)} + \begin{bmatrix*}[r] 4 \\ -1 \\ 1 \end{bmatrix*}
  \]

MODIFIED ORIGINAL
 \[
 \vecd{x}^{(k+1)} = \begin{bmatrix*}[r] \mystrut0 & \tfrac{1}{4} & -\tfrac{1}{4} \\[3pt] \tfrac{1}{3} & 0 & -\tfrac{1}{3} \\[3pt] -\tfrac{1}{5} & -\tfrac{1}{5} & 0\mystrut \end{bmatrix*} \vecd{x}^{(k)} + \begin{bmatrix*}[r] 4 \\ -1 \\ 1 \end{bmatrix*}
  \]

TABSTACKENGINE (1.8baselineskip vertical \& 1.8ex intercolumngap)
\setstackgap{L}{1.8\baselineskip}
\setstackTABgap{1.8ex}
\[
\mathbf{x}^{(k+1)} =
\bracketMatrixstack[r]{
0            &  \frac{1}{4} & -\frac{1}{4}\\
\frac{1}{3}  &            0 & -\frac{1}{3}\\
-\frac{1}{5} & -\frac{1}{5} & 0
}
\mathbf{x}^{(k)} + \bracketVectorstack[r]{4\\-1\\1}
\]
\end{document}

enter image description here

David Carlisle
  • 757,742