4

If my fraction has a taller numerator than denominator, e.g.:

\frac{\begin{array}{c} t\\a\\l\\l\\ \end{array}}{small}

a nice fraction

I like the way it is still adjusted to the baseline.


However, something weird happens if I need to enclose it with \left and \right delimiters, see:

\left(\frac{\begin{array}{c} t\\a\\l\\l\\ \end{array}}{small}\right)

a weird fraction

Why is there so much empty space under the denominator then?
How can I get rid of this empty space while still keeping the fraction bar aligned with the baseline?

I am aware this would imply that the parentheses are not centered with the fraction bar anymore. But I don't mind.

iago-lito
  • 1,472
  • \left and \right just stretch the delimiters keeping them vertically centred on the math axis, and covering the height and depth of the content. Your other option is to use \Biggl( and then raise "by hand" – David Carlisle Mar 03 '17 at 15:12
  • @DavidCarlisle If you don't mind, I will consider this other option a hackish solution ;) If I understand well, \left and \right try to both keepVerticallyCentered and coverHeightAndDepth. How do I optionally disable the first of these two constraints? – iago-lito Mar 03 '17 at 15:18
  • 3
    You can not. TeX does not offer that possibility. If you are really doing this a lot and don't want to raise by hand, first set the inner fraction, measure its height then lower it so it is vertically centred, then add the \left \right, then raise the entire construct by the amount that you lowered. (This is how delarray package puts brackets around a bottom aligned array) – David Carlisle Mar 03 '17 at 15:25
  • @DavidCarlisle Too bad :\ Is there a way I can automatically adapt \Biggl( to the size of my fraction then? And automatically center it right? – iago-lito Mar 03 '17 at 15:27
  • another question addressing this topic: Regarding sizing of delimiters – barbara beeton Mar 03 '17 at 16:06

2 Answers2

4

enter image description here

I'm not sure it looks that nice:-) but if that's what you want:

\documentclass{article}

\def\zzz#1{%
\sbox0{$#1$}%
\dimen0=0.5\dimexpr\ht0+\dp0\relax
\sbox0{$\left(\lower\dimen0 \box0 \right)$}%
\raise\dimen0 \box0 
}


\begin{document}


text here $1+\zzz{\frac{\begin{array}{c} t\\a\\l\\l\\ \end{array}}{small}}$ zzz
\end{document}
David Carlisle
  • 757,742
  • You could fiddle with the exact shift to take account of math axis, and/or decrease the delimitershortfall but this should give the basic idea. – David Carlisle Mar 03 '17 at 15:40
  • \vcenter is suggested in one of the answers to the question to which i posted a link in a comment above. not that i like it ... – barbara beeton Mar 03 '17 at 16:08
  • yes but that's for the option not requested here of keeping the delimters centered but lowing the fraction so it is centred not aligned to the math axis. so it's like this answer with the \lower but not the \raise – David Carlisle Mar 03 '17 at 16:20
  • Interesting, thanks ! Too bad that the shift must be adjusted manually tough.. – iago-lito Mar 06 '17 at 14:54
  • there shouldn't be any manual correction needed, I just meant change 0.5\dimexpr\ht0+\dp0\relax to something more exact then exactly half the height+depth, at least offset by \fontdimen22 (the height of the math axis) – David Carlisle Mar 06 '17 at 15:17
  • @iago-lito but I see you've given the tick to egreg for using my package:-) – David Carlisle Mar 06 '17 at 15:18
  • I did. I find it more easy to use for unititated people. I am sorry you feal jealous because you have so few ticks :P Thank you for delarray by the way! By the way, I am a little upset that TeX internals seem so difficult to access for plain users like me, even with a good level in programmation. Do you not find the content of these \def\zzz{*} and \makeatletter*delfrac*\makeatother really hard to read, to understand and to tweak? – iago-lito Mar 06 '17 at 15:42
  • @iago-lito since I've been doing it for 30 years, no, I can read it fairly easily, but like any language it takes a bit of getting used to. – David Carlisle Mar 06 '17 at 15:45
  • Haha! You're not the right person to be asked about first contact with TeX then ^ ^. But I guess you're right. – iago-lito Mar 06 '17 at 15:46
4

You should use a different way to express your formulas, I believe.

Anyway, here's a possible solution using delarray.

The syntax is

\delfrac<left>{<numerator>}{<denominator>}<right>

If you need brackets [] you have to use \lbrack and \rbrack, for implementation reasons due to delarray.

\documentclass{article}
\usepackage{amsmath}
\usepackage{delarray}


\makeatletter
\newsavebox{\del@frac@box}
\newcommand\delfrac[4]{\mathpalette\del@frac{{#1}{#2}{#3}{#4}}}
\newcommand{\del@frac}[2]{\del@@frac{#1}#2}
\newcommand{\del@@frac}[5]{%
  \sbox\del@frac@box{$\m@th#1\frac{#3}{#4}$}%
  \sbox\z@{$\begin{array}#2{@{}c@{}}#5\usebox{\del@frac@box}\end{array}$}%
  \raisebox{\dimexpr\depth-\dp\del@frac@box}{\box\z@}%
}
\makeatother

\begin{document}

baseline $\left\{\frac{a}{b}\right\}$ $\delfrac\{{a}{b}\}$
$\delfrac\{{\begin{array}{c} t\\a\\l\\l \end{array}}{small}\}$ is here

\[
x+\delfrac\{{\begin{array}{c} t\\a\\l\\l \end{array}}{small}\}+y
\]

\[
x_{t\delfrac\lbrack{\substack{a\\b\\c\mathstrut}}{\substack{\mathstrut d\\e}}\rbrack}
\]
\end{document}

enter image description here

egreg
  • 1,121,712