sciapp / gr

GR framework: a graphics library for visualisation applications
Other
328 stars 55 forks source link

`mathtex2` output looks a bit deformed #105

Closed asinghvi17 closed 4 years ago

asinghvi17 commented 4 years ago

In Julia, executing the following code:

using GR # v0.48
GR.settextfontprec(231, 3)
GR.mathtex(0.1, 0.1, raw"x_{f}=\int_{t_{*}}^{\infty} d t \frac{k}{a^{2}(t)}\sqrt{1+\frac{k^{2}}{a^{2}(t)}}")

yields the image:

Screen Shot 2020-03-31 at 5 08 35  47800PM

Is there a way to make the integral sign larger, and to ensure that the square root's top line maintains its size?

FlorianRhiem commented 4 years ago

Hey, thank you for the bug report. The mathtex parser and the outline font precision are both rather new, so there are still a few adjustments that need to be made for the two to fit together.

I've updated some spacing parameters for the sqrt horizontal rule and get the following result:

image

I've also made a slight change to allow \int and \sum as auto-sizable left delimiters. This allows a formula like this: x_{f}=\left\int_{t_{*}}^{\infty} d t \right. \frac{k}{a^{2}(t)}\sqrt{1+\frac{k^{2}}{a^{2}(t)}} which is then rendered as:

image

Would this be alright for you? Using \int without \left will still yield the regular integration symbol with limits below and above it.

asinghvi17 commented 4 years ago

That looks a lot better; would it be at all possible to have the integration limits in the "correct" places? Another option could be directly right of top for the superscript, and right of bottom for the subscript.

I've also noticed that the \sqrt seems a little thick, and there seems to be a constant right shift at the beginning of each delimiter.

Thanks a lot for the help!

FlorianRhiem commented 4 years ago

Not at this time, though that might be something to look at in the future.

Symbols like \sqrt and \left( are rendered using their regular characters, scaled up to match the required height. This results in characters which are equally wider and thick. I suspect their width is also the cause for the right shift you are noticing.

In your example, a way to decrease the required height is to use \dfrac like this x_{f}=\int_{t_{*}}^{\infty} d t \dfrac{k}{a^{2}(t)}\sqrt{1+\dfrac{k^{2}}{a^{2}(t)}}:

image
FlorianRhiem commented 4 years ago

The changes have been merged into develop and will be part of the next minor release.