1

For example, in the actual .tex file, I'd like sentences like this:

Due to this,
some reasonable conclusion.
Next sentence.

To be formatted like this:

Due to this,
   some reasonable conclusion.
Next sentence.

Ideally this formatting would happen while typing (e.g., after pressing ',\n', or '\ns').

I use line breaks for each sentence in Latex. This works great most of the time. However there are times where I have a long sentence that hits the line break for my editor that I do not want to shorten. So currently I am breaking these longer sentences at some semantic break point (e.g., a comma). But I would like to visually be able to quickly see where these multi-line sentences occur in my document. So I'd like all lines but the first line in a multi-line sentence to be indented.

Is this possible in Latex? I'm using the vim latex-suite plugin currently.

6
  • Could this answer: tex.stackexchange.com/a/147154/38080 helps? The hanging package should do what you want.
    – Rmano
    Jan 8, 2014 at 20:55
  • @Rmano -- I assume he means in the actual .tex file, not in the output; 'in Latex' is rather vague, but 'for my editor' seems almost clear enough.
    – jon
    Jan 8, 2014 at 21:00
  • @jon --- you're right, I missed that.
    – Rmano
    Jan 8, 2014 at 21:02
  • Just to be clear: you want to keep breaking the line manually? So it is not just a matter of indenting when the line is automatically wrapped? Because I'm not sure, in that case, how the editor is supposed to distinguish 'another line of the same sentence' from 'the first line of a new sentence'. Upper/lower case etc. might approximate this but won't an approximation be the best you can do?
    – cfr
    Jan 8, 2014 at 22:15
  • @cfr That's exactly what I'd like the editor to do: "distinguish 'another line of the same sentence' from 'the first line of a new sentence'". I would think you could get pretty accurate working from that last character in the preceding sentence (e.g., is it a period, question mark, etc.). I was hoping that someone had already written the code that handles all of the corner 'gotcha' cases. Well, Latex knows how to identify end of sentences, since there are spacing parameters for whitespace between sentences. Maybe one way is to tap into the Latex engine. Jan 8, 2014 at 22:17

1 Answer 1

6

A first approximation would be to indent every line starting with a lower case letter by 4 spaces so a regex replace

s/^\s*([a-z])/    \1/

in sed or perl or emacs or vim (I assume:-)

LaTeX doesn't even see any white space at start of line except in verbatim environments so it doesn't matter what indentation you use as far as LaTeX is concerned.

3
  • What do you think my chances are for hooking this into the indentation function for latex-suite. Well wait, that's impossible, unless the indentation can be relooked at and updated after I type the first letter of the line. Jan 8, 2014 at 21:50
  • 5
    @ClaytonStanley The only things I know about vim are that esc :q gets me out of it if I get there by mistake, and that it's not emacs, so I may not be the best person for detailed vim customisation:-) Jan 8, 2014 at 21:54
  • For reference, I found that perl -p -i -e 's/^([a-z])/ \1/' *.tex worked well for my use case. Jan 9, 2014 at 20:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .