Skip to content
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

LaTeX: preserving math sections #69

Closed
timtro opened this issue Jan 21, 2018 · 7 comments
Closed

LaTeX: preserving math sections #69

timtro opened this issue Jan 21, 2018 · 7 comments

Comments

@timtro
Copy link

timtro commented Jan 21, 2018

Thanks for a remarkably useful and versatile extension. I'm aware that you don't often use LaTeX, so I'm especially thankful that you're supporting it.

If I have long inline-math, I put the code on separate lines. Eg:

Some text explaining deep and profound ideas, that needs some inline math
$
  …
$

Rewrap correctly ignores my linebreaks and wraps that all up. So to suppress that behaviour, I tried leaving a trailing comment:

Some text explaining deep and profound ideas, that needs some inline math % ← Trailing comment 
$
  …
$

but Rewrap pulls the opening dollar-sign up after the trailing %, which creates a delimiter mismatch!

Some text explaining deep and profound ideas, that needs some inline math % $ ← Yikes!
  …
$
@stkb
Copy link
Owner

stkb commented Jan 22, 2018

I still need to add support for end of line comments (#46). At the moment they're just seen as normal paragraph text so don't do anything special.

The problem is the math section isn't recognised either. I think you like it if that section was preserved anyway? (Like #68).

For example:

Normal text that can      ->      Normal text that |
get reflowed.    |                can get reflowed.|
$                |                $                |
    Math:        |                    Math:        |
      don't touch this                  don't touch this
$                |                $                |

I can add that for all math environments (\begin{math|displaymath|equation} ... \end{...}, as well as the shortcuts (\(...\), \[...]\, $...$, $$...$$) when the begin/end markers are on otherwise empty lines.

@timtro
Copy link
Author

timtro commented Jan 22, 2018

Thanks for your reply.

when the begin/end markers are on otherwise empty lines.

Actually, that's perfect!

Regardless of my personal style, most users would expect normal paragraph reflow for inline math (i.e., $...$, \(...\) and \begin/end{math}). But it makes perfect sense that if the delimiters are on their own lines, that the user intends them to remain that way.

Here is a more comprehensive list of math environments in common usage, including those from the amsmath 1 package.

  • \( and \)
  • \[ and \]
  • $ and $
  • $$ and $$
  • \begin{equation} and \end{equation}
  • \begin{equation*} and \end{equation*}
  • \begin{multline} and \end{multline} with multline* variant
  • \begin{align} and \end{align} with align* variant
  • \begin{gather} and \end{gather} with gather* variant
  • \begin{math} and \end{math}
  • \begin{displaymath} and \end{displaymath}

Edit: -Facepalm- I just realised that all of the begin/end variants can be covered in general, and you probably didn't need all of those specific cases.

Footnotes

  1. The amsmath package is ubiquitous and is included by default in nearly every publisher's class or style. Basic LaTeX only covers the common case of centred single line display expressions and inline math.

@stkb
Copy link
Owner

stkb commented Jan 26, 2018

Fantastic, thanks for all that info! I did hope to have a beta ready by now, but there were a few complications. I should get time in the weekend to do it.

@stkb stkb changed the title LaTeX trailing comment should prevent wrap LaTeX: preserving math sections Jan 26, 2018
@stkb
Copy link
Owner

stkb commented Jan 29, 2018

Ok I've just released a beta version which has this addition.

The list of math environments was indeed helpful, since only in those should all text be preserved verbatim.

If you'd like to test it (I'd be grateful :)) you can download/install the beta from https://github.com/stkb/Rewrap/releases/tag/v1.7.0-beta1

I'm planning to release the next version properly in a week's time, after tackling some of the other issues.

Edit: forgot to say, basic rules for how it works are here

@timtro
Copy link
Author

timtro commented Jan 30, 2018

Sure, I'd be happy to test it. I'll put it through some paces tomorrow.

@stkb
Copy link
Owner

stkb commented Feb 4, 2018

It's now in v1.7.0. Will close this now but let me know if anything's not working as expected. Other issues to improve LaTeX are also welcome.

@stkb stkb closed this as completed Feb 4, 2018
@timtro
Copy link
Author

timtro commented Feb 12, 2018

Thanks. Sorry, I got landed with a pretty full plate that I'm still trying to work through. I will let you know if there are any problems.

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

No branches or pull requests

2 participants