Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Support \underline in Mathtext. #23616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Support \underline in Mathtext. #23616

wants to merge 3 commits into from

Conversation

tfpf
Copy link
Contributor

@tfpf tfpf commented Aug 14, 2022

PR Summary

#15624 hasn't seen any activity for a while, so I went ahead with this.

Note that the underline is drawn below the lowest descender. This is consistent with TeX. (The PNG images suffer from what I assume is pixel rounding.)

Fixes #14235.
Closes #15624

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • [N/A] API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

@tfpf tfpf marked this pull request as ready for review August 14, 2022 13:06
@oscargus
Copy link
Member

Looks good! I think it makes sense to add a brief What's new for this to make users aware that it is added.

Also, I think it may be enough to have a "lightweight" test for this as it doesn't seem very dependent on the font:

# 'lightweight' tests test only a single fontset (dejavusans, which is the
# default) and only png outputs, in order to minimize the size of baseline
# images.
lightweight_math_tests = [
r'$\sqrt[ab]{123}$', # github issue #8665
r'$x \overset{f}{\rightarrow} \overset{f}{x} \underset{xx}{ff} \overset{xx}{ff} \underset{f}{x} \underset{f}{\leftarrow} x$', # github issue #18241
r'$\sum x\quad\sum^nx\quad\sum_nx\quad\sum_n^nx\quad\prod x\quad\prod^nx\quad\prod_nx\quad\prod_n^nx$', # GitHub issue 18085
r'$1.$ $2.$ $19680801.$ $a.$ $b.$ $mpl.$',
]

@timhoffm timhoffm requested a review from anntzer August 15, 2022 08:04
@timhoffm
Copy link
Member

@anntzer I think you as our TeX expert should review this.

@anntzer
Copy link
Contributor

anntzer commented Aug 15, 2022

Sure, l'll need a couple of days though.

@anntzer
Copy link
Contributor

anntzer commented Aug 18, 2022

This seems reasonable, but 1) do you know why the overline() implementation is so different, using a fill instead? (which seems inconsistent with the TeXbook); 2) the TeXbook (rules G9/G10 p443) add an extra thickness of whitespace clearance over the overline / under the underline; do you know why they are not needed here (if they indeed aren't)?

@tfpf
Copy link
Contributor Author

tfpf commented Aug 20, 2022

the TeXbook (rules G9/G10 p443) add an extra thickness of whitespace clearance over the overline / under the underline

I think that extra space is used to set the minimum leading.

more_leading
If the leading is high, the vertical distance between the tops of the Ts and the underscores on the previous lines remains unchanged even if the underscores are underlined. (As if the underline wasn't there at all.)

less_leading
Upon reducing the leading, the Ts remain some distance away from the underline. It's like the underline forces the next line to go lower if it is too close.

I have not looked through Mathtext's leading rules, but it certainly looks like it's better to follow what TeX does. I will update this. Getting second thoughts about this now. Should I add that space at the bottom, or leave this as it is?

do you know why the overline() implementation is so different, using a fill instead

That's a good question, one which I wondered myself, but couldn't figure out. In fact, I haven't completely understood how glue works in Mathtext.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add \underline to mathtext?
4 participants