Converting a Lyx document to LaTeX: removing line breaks / carriage returns / split lines using Emacs

by krisrowland

I recently wanted to convert a Lyx document into plain LaTeX. The process is relatively easy: File -> Export -> Plain LaTeX. The resultant .tex file, however, has multiple line breaks throughout every paragraph. Uuuugh… UGLY! (Not to mention clunky and unusable).

My fix for this surely isn’t the best, but it’s better than removing the trailing carriage returns manually. First, select a paragraph. then search for all (hidden) line breaks, replacing them with a space:

meta-x replace-string

^q ^j


That’s it. All line breaks will be replaced by spaces in that paragraph. I’m not sure how to do a full document replacement since all carriage return marks will be replaced (concatenating all paragraphs etc.); not what you want.