02 March 2010

TeX text files

Questions for those who use LaTeX by editing text files (as opposed to those who use a WYSIWYG editor like LyX).

Do you use the line wrapping feature in your editor and keep each paragraph on one line or do you usually put paragraphs on multiple lines? If the latter is true then how do you maintain the lines so they aren't too long or too short? Manually or automatically? If automatically, then do you use a program like par, a feature of your editor, or something else? If you use par, then how do you keep it from messing things like \begin {equation}…\end{equation} and \begin {verbatim}…\end{verbatim}? (The latter is in a paragraph of its own, but the former usually not.)


Cristian George Strat said...

Multiple lines. I use 'gq' in vim to wrap. I don't think it does anything special but if you help it a bit by selecting only a few lines at a time it does the job.

Andy said...

Emacs, multiple lines, emacs, fill-paragraph triggered by hitting M-q (but no autofill, I found that annoying).

LaTeX-mode in emacs is intelligent enough to deal with semantic structure like \begin and \end pretty well, handles indentation of list \items ok, etc. (Actually some of that depends on what emacs you're using - a few years ago on linux it seemed to work better than now, using gnu emacs on OSX; not sure why, not annoyed by it enough to work out how to fix it.)

rgrig said...

@Cristi: Thanks, I use ViM but I forgot about 'gq'. Instead I mapped <F9> to an external tool (par) that does formatting. This tool is quite versatile and ViM's help recommends it for more fancy formatting (e.g., justified or right aligned). However, I never use those features, so I should probably stick to 'gq'.

@Andy (and @John Mark who replied on messenger): Thanks, I didn't realize that emacs handles LaTeX environments properly. That sounds like a good reason to move back to emacs :)

Background: I was annoyed to select lines every time in ViM. I asked what people do partly because I wanted to know if there's a better way.

I wrote a small tool that handles (some) LaTeX environments and now I use it instead of 'par'. I asked also because I wanted to know if other people would find the tool useful. If so, I should put some thought into it, as opposed to hack it until it kinda works :)

Thanks to your answers, I know that emacs behaves properly by default. I'm still hoping there's a better way in ViM that I don't know of.

rgrig said...

There is a thread about an equivalent for M-q in ViM on the vim_use mailing list.

Anonymous said...

I use emacs and put every sentence on a new line, with two newlines to separate paragraphs. For wrappings, I use emacs new visual line mode.

The advantage here is that the version control diffs are very readable, since the sentences that change get highlighted.

rgrig said...

@Anonymous: I seldom use diffs, but maybe that's because they are hard to read. I will try to write one sentence per line in the next document and see how it goes. I'm a little worried that the jagged appearance will be displeasing. Thanks for the idea.

rgrig said...
This comment has been removed by the author.
Michaƫl Cadilhac said...

Emacs user here. I use AucTeX for LaTeX editing ; a colleague of mine uses PreviewDVI to get preview within Emacs, that's nice, but I'm not sure I like it.

Filling with Emacs, I use auto-fill-mode (for which I find no annoyance), and usually do a M-x fill-individual-paragraphs when the file has been... cluttered by a coauthor. For diff, BTW, you can probably work out something nice with wdiff (GNU wrapper for diff to only show differences in words).

rgrig said...

Michael, I didn't know about wdiff. Thanks!

Damien Cassou said...

Within emacs, one can see pretty diffs using ediff. It is even integrated with at least magit and psvn.


Post a Comment

Note: (1) You need to have third-party cookies enabled in order to comment on Blogger. (2) Better to copy your comment before hitting publish/preview. Blogger sometimes eats comments on the first try, but the second works. Crazy Blogger.