0

Consider the following piece of text

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
$$e^ix = cos(x) + i \dot sin(x)$$
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore

The text is overly long so want to org-fill-paragraph it. Unfortunately M-q yields

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore $$e^ix = cos(x) + i \dot
sin(x)$$ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed
do eiusmod tempor incididunt ut labore et dolore

which puts the formula within the text making it hard to read.

What can I do to make Emacs fill the text but keep the formula between $$ on its own line?

I looked at this answer but couldn't make it work. I'm also hoping for a simpler solution for what I suspect is a common use case.

5
  • You can make each long line its own paragraph by inserting newlines before and after the formula, use org-fill-paragraph on each paragraph and then delete the extra newlines. Otherwise, the while thing is one paragraph and is formatted as such. – NickD Sep 3 '20 at 20:23
  • Thanks, that’s what I do now. Is there really nothing more elegant? – Bob Jansen Sep 3 '20 at 20:28
  • Nothing that I know of. – NickD Sep 3 '20 at 20:37
  • In your specific example, since the formula is a displayed formula in the LaTeX output, you might as well make it a separate paragraph in the Org mode file as well (IOW, embrace the extra newlines). But that wouldn't help e.g. with an inline formula. – NickD Sep 3 '20 at 20:41
  • In LaTeX output that will have the subtle difference that the next line will be treated as a new paragraph and thus be indented. This is only sometimes what you want :( – Bob Jansen Sep 3 '20 at 20:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.