Feature request for mathtext

Hi,

a big thanks to all matplotlib developers. This is a great tool! (I thought this needs to be said once on a while)

I would like to propose a small feature addition to the mathtext module. It has a \overline command but is missing the corresponding \underline command which LaTeX supports.
I took the liberty to edit the _mathtext.py file and added a \underline command by cloning
and slightly modifying the \overline parts.

Would be great if this in some form or other becomes part of future matplotlib releases.

Thanks,
Lothar

#_mathtext.py parts

Also needs to add something in the definitions part where p.overline is defined

The function itself

def underline(self, toks: ParseResults) -> T.Any:
    body = toks["body"]

    state = self.get_state()
    thickness = state.get_current_underline_thickness()

    height = body.height - body.shift_amount + thickness * 3.0
    depth = body.depth + body.shift_amount

    # Place underline below body
    rightside = Vlist([Hlist([body]), Glue('fill'), \
                       Hrule(state,thickness=0.75*thickness)])

    # Stretch the glue between the hrule and the body
    rightside.vpack(height + (state.fontsize * state.dpi) / (100.0 * 12.0),
                    'exactly', depth)
    # shift downwards so that characters have roughly same baseline
    rightside.shift_amount = thickness * 5.0 

    hlist = Hlist([rightside])
    return [hlist]

Hi @lbirk thanks for the suggestion! There is actually already an open GitHub issue to track this and even a pull request although that seems to have stalled. If you would be interested in opening a new PR to implement this, I think that would be welcome.

Hi Ruth,

I would be willing to do it (since I have a working version) but I am
new to GitHub and never worked on a project as big as this. How would
I go about it? :slight_smile:

Lothar

···

On 9/1/24 12:10, Ruth Comer via Matplotlib wrote:

[rcomer] rcomer https://discourse.matplotlib.org/u/rcomer
September 1

Hi @lbirk https://discourse.matplotlib.org/u/lbirk thanks for the
suggestion! There is actually already an open GitHub issue <https://
Add \underline to mathtext? · Issue #14235 · matplotlib/matplotlib · GitHub> to track this and even a
pull request https://github.com/matplotlib/matplotlib/pull/23616
although that seems to have stalled. If you would be interested in
opening a new PR to implement this, I think that would be welcome.


Visit Topic <https://discourse.matplotlib.org/t/feature-request-for-
mathtext/24648/2> or reply to this email to respond.

To unsubscribe from these emails, click here <https://
discourse.matplotlib.org/email/unsubscribe/
d167c6a1febc3e9dd491ab38fad89d29b6f13b77cd2ae1a12f625e413f2eab71>.

Great! We have a Contributors’ Guide here, which includes git and github instructions: Contribute — Matplotlib 3.10.0.dev626+g3a0bc88a2d documentation