TransWikia.com

Automatic brackets size with left(...right) fails for text{...} exponents

TeX - LaTeX Asked by audiophiel on January 10, 2021

I noticed that the automatic adjustment size for parentheses by use of left(...right) "fails" in two cases I use a lot:

Case one:

When a upper index is set as text{...}. I typeset label-indices as text{...} (for example $y^text{p}$ for predicted y-values) since this is how they are usually formatted in the physics context to distinguish labels from mathematical indices.

I marked the upper and lower ends of the parentheses for just brackets (green), left(...right) (red) and left(...^text{...}right) (blue). Note that the bracket size for the latter is adjusted, but not to the right size.
enter image description here

Case two:

When having large equations in parentheses spanning multiple lines, I break the lines with

begin{align}
    left[ ... right. 
    left. ... right]
end{align}

In this case, the size of the square brackets is not adjusted synchronously. I understand that this is because the size is determined within a line instead of within the left[...right] pair.

Question:

The question connecting this two cases is: Is it possible to access the logic of how the sizes are determined? (Another use case is to increase nested brackets automatically).

Example:

enter image description here

MWE:

documentclass[preview]{standalone}

usepackage{amsmath}
usepackage{listings}
lstset{language=TeX,
    basicstyle=footnotesizettfamily,
}
begin{document}

Case one:
begin{align*}
    (y_i^f) + left(y_i^fright) + left(y_i^text{f}right)
end{align*}


Case two:
begin{align*}
    y=& left[ frac{x}{c} right. 
    &+left. f(x)right]
end{align*}
end{document} 

One Answer

enter image description here

documentclass{article}

usepackage{amsmath}

begin{document}

[
left(y^f_iright) left(y^{text{f}}_iright) left(y^{mathrm{f}}_iright) 
]
end{document}

The italic f is raised higher to keep it away from the subscript so simply forces TeX to choose an overlarge delimiter size. This demonstrates why it is usually better to choose the size manually with a simple ( or an explicit bigl(...bigr) pair if a larger size is needed.

So the automatically chosen size is Ok for mathrm (which should be used in preference to text) although personally I would just use the default size here and not use leftright at all:

enter image description here

[
(y^{mathrm{f}}_i)left(y^{mathrm{f}}_iright) 
]

Answered by David Carlisle on January 10, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP