Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

If you see here, the author mentions an "official version" of an indentation script from Johannes Zellner. The link is broken and while there are traces of Zellner all over the interwebs, I can't find the script.

Maybe there is a more up to date, somehow "official" (e.g. endorsed by TUG or some community, such as this one!) script for TeX indentation in Vim? (Or more particularly, in Vim+Latex-Suite, not that that really should make a difference?)

If not, I'll probably customize Tanzler's script, in which case, my question becomes "what are the best practices for TeX source indentation"?

I'm inclined to do

First sentence of new paragraph
    continuation of first sentence.
    Second sentence of paragraph
        continuation of second sentence.
    Third sentence of paragraph
        continuation.
    \begin{environment}
        \item First item
                continuation of first item
        \item Second item
    \end{environment}

etc., but if there are established best practices for TeX source indentation, I will follow them instead.

EDIT: Screenshots illustrating @J.C.Salomon 's explanation.

My original way:

My way of indentation--diff highlights too many changes

Suggested better way:

His way--only relevant changes are highlighted

share|improve this question
3  
I wouldn’t indent sentences & phrases that way. Per my answer at <tex.stackexchange.com/a/64538/2966>; though, breaking lines at sentence- and significant phrase-boundaries might well be a good idea, especially if you’re using some sort of VCS to record edits you make. –  J. C. Salomon Aug 6 '12 at 3:51
    
That said, the way you’ve indented the environment & the \item lines within it are fairly standard. –  J. C. Salomon Aug 6 '12 at 3:52
    
I do tend to use phrase-boundaries when possible to split sentences across lines, but I find it easier to scan across sentences when they have a bit more indentation. I'm not wedded to any style though. –  Philip Aug 6 '12 at 19:59
1  
Extra indentation means that splitting or joining paragraphs have a larger diff than needed in the version-control system you’re using. –  J. C. Salomon Aug 7 '12 at 3:18
1  
Write a plain text file with a four-sentence paragraph according to your indentation scheme. Split the paragraph after the second sentence. Run diff on the two versions. Then try the experiment without that indentation. Compare the diffs: which has less uninteresting information? –  J. C. Salomon Aug 7 '12 at 21:14
show 2 more comments

1 Answer

up vote 7 down vote accepted

There are no real standards, but here are some tips I’ve found handy:

Don’t indent parts of a paragraph, but do break lines between sentences and after significant phrases within a sentence. As I posted at http://tex.stackexchange.com/a/64538/2966, this makes it easier for small edits to have small diffs. (You are using a VCS, aren’t you?) To exaggerate my own tendency toward long sentences (which benefit even more from this tip), here’s an example:

I tend toward long sentences with many dependent clauses,
and my rewrites often combine or split these,
so standard advice
about breaking lines at sentence boundaries
is not quite enough for me;
I’ve therefore gone beyond those tips,
all the way to writing my prose as if it were blank verse:
breaking lines at most punctuation points
and at other phrase boundaries.

For readability, indent the content of most environments. The small ones, at least; indenting everything between \begin{document} and \end{document} is rather pointless. Spaces or tabs, or the depth of the indent, are all up to you. Just stay consistent within a document.

(Expl3 code does have a more well-defined indentation style. If you’re playing with Expl3 code, you know what it looks like. Follow that style religiously, or your code will be unreadable.)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.