# How can I get a fraction with a matrix in the numerator and denominator?

The above fraction is what I would like to achieve

What I have so far is

$\begin{bmatrix} 0 \\ 0 \\ 1 \\ 1 \end{bmatrix} - \frac{ \begin{bmatrix} 0 & 0 & 1 & 1 \end{bmatrix} \begin{bmatrix} 1 \\ 1 \\ 1 \\ 1 \end{bmatrix}}{\begin{bmatrix} 1 & 1 & 1 & 1 \end{bmatrix} \begin{bmatrix} 1 \\ 1 \\ 1 \\ 1 \end{bmatrix} }$


and it looks like this

How can I achieve my desired result?

• You also get several errors from that input. – egreg Nov 14 '18 at 17:09
• what are the errors? my code compiles so I didn't notice any errors – user130306 Nov 14 '18 at 17:16
• The second $ causes TeX to leave math mode before your equation is finished. You should put it all the way at the end (after \end{bmatrix} }). You may want to instead use $...$ or $$...$$instead of $...$ since this looks like a display equation rather than an inline equation. – Circumscribe Nov 14 '18 at 17:20 • The fixed code compiles normally and has the expected result for me. – Bernard Nov 14 '18 at 17:25 • yes I know, I corrected the misplaced $ and got my desired outcome so my question no longer needs an answer – user130306 Nov 14 '18 at 18:27

You could use the bsmallmatrix environment, provided by the mathtools package, to render the row and column vectors in the \frac expression more compactly.

\documentclass{article}
\usepackage{mathtools}
\begin{document}
$\begin{bmatrix} 0 \\ 0 \\ 1 \\ 1 \end{bmatrix} - \frac{ \begin{bsmallmatrix} 0 & 0 & 1 & 1 \end{bsmallmatrix} \begin{bsmallmatrix} 1 \\ 1 \\ 1 \\ 1 \end{bsmallmatrix}}{% \begin{bsmallmatrix} 1 & 1 & 1 & 1 \end{bsmallmatrix} \begin{bsmallmatrix} 1 \\ 1 \\ 1 \\ 1 \end{bsmallmatrix} } \begin{bmatrix} 1 \\ 1 \\ 1 \\ 1 \end{bmatrix}$
\end{document}

\documentclass{article}
\usepackage{tabstackengine}
\stackMath
\begin{document}
$\setstacktabbedgap{1ex} \bracketVectorstack{0\\0\\1\\1} - \Frac{ \bracketMatrixstack{0&0&1&1}\bracketVectorstack{1\\1\\1\\1} }{ \bracketMatrixstack{1&1&1&1}\bracketVectorstack{1\\1\\1\\1} } \bracketVectorstack{1\\1\\1\\1}$
\end{document}


The smaller size of \Frac is also possible, with a small redefinition:

\documentclass{article}
\usepackage{tabstackengine}
\stackMath
\newcommand\Frac[2]{{%
\setstackgap{L}{.7\normalbaselineskip}\TABstackMathstyle{\scriptstyle}%
$\setstacktabbedgap{1ex} \bracketVectorstack{0\\0\\1\\1} - \Frac{ \bracketMatrixstack{0&0&1&1}\bracketMatrixstack{1\\1\\1\\1} }{ \bracketMatrixstack{1&1&1&1}\bracketMatrixstack{1\\1\\1\\1} } \bracketVectorstack{1\\1\\1\\1}$