Skip to content

LaTeX compatibility #90

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

Closed
wants to merge 4 commits into from
Closed

LaTeX compatibility #90

wants to merge 4 commits into from

Conversation

joshuarayton
Copy link
Contributor

@joshuarayton joshuarayton commented Jul 24, 2024

Improved $\LaTeX$ compatibility for more advanced converters like libtexprintf.

Before After


Step by step latex2text converter:

utftex converter:

Initial compatibility fix:

Removed trailing whitespace:

Variables for lines above and below $\LaTeX$ blocks (both set to 1):

@MeanderingProgrammer
Copy link
Owner

As far as I can tell this isn't so much about compatibility and more just adds padding around latex blocks. Is that right?

@joshuarayton
Copy link
Contributor Author

As far as I can tell this isn't so much about compatibility and more just adds padding around latex blocks. Is that right?

The previous behaviour was to remove leading and trailing whitespace from the inputter and converter. This breaks more advanced renderers which utilise whitespace to align elements on different levels.

Before fix:

The following are not aligned properly:

  • The infinity in the summation
  • The denominator in the summation
  • The exponent of Euler's identity
  • The vinculum of the square root in a variation of the Pythagorean theorem

After initial fix:

Those alignment errors are fixed however the previous behaviour did not have an empty line at the end of the block so that was changed to keep old behaviour:

For longer equations I felt this was too close together so I added variables to change the amount of empty lines above and below LaTeX blocks:

In this image they are both set to one because that is my preference but the default values are 0 to keep the old behaviour.

These changes don't change the old behaviour much (whitespace from the inputter is kept which is different, but I feel this is better), only adds new behaviour which fixes compatibility for more LaTeX to text converters.

@MeanderingProgrammer
Copy link
Owner

Thanks for the info! Makes sense to me.

Merged this here: 695501b

Used vim.split(raw_expression, '\n', { plain = true, trimempty = true }) in favor of removing the last line with table.remove(expressions, nil). Since what we really want to do is remove any leading and trailing empty lines and keep the internal ones for spacing. Removed usage of vim.trim like in this PR so things get put in the right place.

Used top_pad and bottom_pad instead of lines_above and lines_below just to stay consistent with the rest of padding related options.

Please update and LMK if it still does what you expect, thanks again!

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

Successfully merging this pull request may close these issues.

2 participants