1

A fraction like this

\frac{1}{\begin{vmatrix}
1 & 2 & 3\\ 
4 & 5 & 6\\ 
7 & 8 & 9
\end{vmatrix}}

is nicely rendered as

enter image description here

but when we enclose it in any kind of delimiters, LaTeX goes stupid and add a lot of space so the numerator and denominator have the same size:

\left(
\frac{1}{\begin{vmatrix}
1 & 2 & 3\\ 
4 & 5 & 6\\ 
7 & 8 & 9
\end{vmatrix}}
\right)

renders as

enter image description here

How can I change this behavior?

Here's the same question, but the "answers" change the semantics of the content, which is, in my opinion, a very bad answer. I don't want to know how can I rewrite my formula to accommodate LaTeX limitations, I want LaTeX to render in a non-stupid manner.

In that post there is an answer that actually try to do this, suggesting the use of the macro \stretchleftright from the package scalerel. The problem with that approach is that the delimiters grows proportionally and will look extremely thick when the fraction is big.

Is there a better way to do that?

7
  • Please bare with me: In any mathematical expression, the middle bar of the main fraction should always be centered around the equal and/or minus signs. This rule has priority over excessive space when you put parentheses around such unbalanced expression. This is the reason why printed mathematics book writes something like Let $D$ be the determinant; that is, \[ D=\begin{vmatrix} 1 & 2 & 3\\ 4 & 5 & 6\\ 7 & 8 & 9 \end{vmatrix}. \] Then \[ ... = \frac{1}{D} ... \], rather than sticking a huge expression in the denominator. Sep 2, 2021 at 4:08
  • @RuixiZhang Ok, I understand now why LaTeX behaves differently with the delimiters, thank you. Still, I'm not interested in changing the structure of my formulas. I'm not doing this for a printed book and I want to be able to stick a big ugly expression either in the numerator or the denominator whenever I want :)
    – jjagmath
    Sep 2, 2021 at 4:38
  • In that case, check the command \centerfraction{...} from my answer and see if that works for you. Sep 2, 2021 at 4:39
  • Yes, I think \centerfraction is what I was looking for. Thank you.
    – jjagmath
    Sep 2, 2021 at 4:52
  • 1
    the behaviour is not stupid it is by design as and the answers you show give ways to get other output Sep 2, 2021 at 6:03

2 Answers 2

1

I propose this simple solution: nestin the fraction in a pmatrix environment:

\documentclass{article}
\usepackage{amsmath}

 \begin{document}

 \[ \begin{pmatrix} \dfrac{1}{\begin{vmatrix}
    1 & 2 & 3\\
    4 & 5 & 6\\
    7 & 8 & 9
    \end{vmatrix}}\end{pmatrix} \]%

\end{document} 

enter image description here

3
  • Thank you. The delimiters I'm using are not always parenthesis, that's why I consistently used the word "delimiters" in my question. But I see your idea with others delimiters and matrix works just fine.
    – jjagmath
    Sep 2, 2021 at 10:07
  • You can change the type of matrix environment (bmatrix, Bmatrix, vmatrix, Vmatrix). As far as I know, the only difficulty would be if you need \l/rfloor or \l/rceil.
    – Bernard
    Sep 2, 2021 at 10:23
  • Exactly, I was using floors
    – jjagmath
    Sep 2, 2021 at 10:54
2
\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newcommand*\centerfraction{\mathpalette\@centerfraction}
\newcommand*\@centerfraction[2]{%
  \vcenter{\hbox{$#1#2\m@th$}}%
}
\makeatother

\begin{document}
Neither of the following looks good:
\[
A^{-1}
=\left(
\frac{1}{\begin{vmatrix}
1 & 2 & 3\\ 
4 & 5 & 6\\ 
7 & 8 & 9
\end{vmatrix}}
\right)
=\left(
\centerfraction{\frac{1}{\begin{vmatrix}
1 & 2 & 3\\ 
4 & 5 & 6\\ 
7 & 8 & 9
\end{vmatrix}}}
\right)
\]
Don't you agree?

How about this: Let $D$ be the determinant; that is,
\[
D=\begin{vmatrix}
1 & 2 & 3\\ 
4 & 5 & 6\\ 
7 & 8 & 9
\end{vmatrix}
\]
Then
\[
A^{-1}=\frac{1}{D}
\quad\text{and}\quad
A^{-1}B=\left(\frac{1}{D}\right)B.
\]
\end{document}

center fraction

The use of \centerfraction{<something with excessive space that you want to get rid of>} is not endorsed by me. Please give the alternative writing style a go.

5
  • The formulas I want to write actually have no matrices nor determinants, the denominator and the denominator are both way more complex expressions involving more nested delimiters and fractions, sums, etc. I changed the expression to make my question simpler and focus on my issue. I also specifically stated in my question that I wasn't interested in rewriting my formula.
    – jjagmath
    Sep 2, 2021 at 4:48
  • 1
    @jjagmath - You write, "The formulas I want to write actually have no matrices nor determinants, the denominator and the denominator are both way more complex expressions involving more nested delimiters and fractions, sums, etc". And how is anyone supposed to know that?
    – Mico
    Sep 2, 2021 at 7:41
  • @jjagmath In addition to Mico's comment, I'd like to remark that complicated formulas are not really helpful for readers and trying to simplify them is something that authors should strive for.
    – egreg
    Sep 2, 2021 at 9:53
  • @egreg What if the purpose of what I'm writing is to exemplify how obfuscated formulas look when you write them like that?
    – jjagmath
    Sep 2, 2021 at 10:00
  • @jjagmath But if that’s you purpose, an “ugly” fraction would support the goal of “exemplifying how obfuscated formulas look”, wouldn’t it? In any case, both Bernard’s and my solutions work, but you’ll need to add code to your existing code. Bernard’s solution is simple but needs more keystrokes here and there; while mine needs only a few extra keystrokes. Moreover, what if you eventually decide to switch back to “ugly” fraction? Using my solution you’d just redefine \renewcommand*\centerfraction[1]{#1} and be done; while with Bernard’s you need to delete the nested matrices one by one. Sep 2, 2021 at 15:20

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.