auctex
[Top][All Lists]

## Re: [AUCTeX] [preview-latex] Play nice with fill-paragraph and/or auto-f

 From: Tassilo Horn Subject: Re: [AUCTeX] [preview-latex] Play nice with fill-paragraph and/or auto-fill-mode or longlines-mode Date: Mon, 10 Mar 2014 12:45:22 +0100 User-agent: Gnus/5.13001 (Ma Gnus v0.10) Emacs/24.3.50 (gnu/linux)

Johannes <address@hidden> writes:

Hi Johannes,

> The result are lines, that use actual newline characters to limit the
> length of each line (to the value fill-column). If the line contains a
> formula this could look like this example:
>
> Lorem ipsum dolor sit amet, consectetur $\int_0^t x^2 > + x dx$ veniam, quis nostrud exercitation ullamco.
>
> Preview latex will render the math expression and put it in line first line
> and emacs will put everything on one long line.
>
> Proposed Solution:
> If the expression replaced by preview-latex contains a newline
> character, a newline character should be appended or prepended to the
> replacing expression.
>
> Is this possible?

Yes, it's possible in general by adding a linebreak as before-string or
after-string property to the overlay.  However, then the text you see
when moving point into the preview image doesn't really match the
original text.

There might be a better (but more sophisticated approach), but I'm not
sure if there's big value in adding even more complexity to preview
here.  I mean, your general intent is to have the text layout look
sensibly wrapped no matter if we're displaying just the text or the
preview images, but since the size of the formula doesn't strictly
correspond to the preview image, there's not much we can do.

For example, with this longer snippet

Lorem ipsum dolor sit amet, consectetur $\int_0^t x^2 + x dx \cdot \frac{x^2}{x - t}$ veniam, quis nostrud
exercitation ullamco.  Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet.

the current preview

Lorem ipsum dolor sit amet, consectetur [img] veniam, quis nostrud
exercitation ullamco. Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet.

probably looks better than a preview that would add some linebreak
somewhere

Lorem ipsum dolor sit amet, consectetur [img]
veniam, quis nostrud
exercitation ullamco.  Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet.

That is, the current preview generates a line that looks too long
whereas an "improved" preview creates a line that looks to short.

I think the best you can do is using visual-line-mode' instead of hard
line-wrapping.

Bye,
Tassilo

`