Here is a part of my LaTeX code and what I want it to be:


However, if I re-indent it in Sublime Text 3, it becomes:


Then the folding function is also invalid, how do I fix this? I'm using LaTeXTools.


You should use the plugin latexindent. Please see here for the documentation and the download.

Here is an example how to use it with arara and how the code looks after the indentation.

% arara: pdflatex
% arara: indent: { overwrite : yes }


        l & l & l & X & X & X & X \\ 

I found that albertxing's gist worked for me in ST3. To summarize, paste & save as LaTeX/Indentation Rules.tmPreferences in your user profile folder (Sublime's Preferences > Browse Packages > LatexTools). Restart Sublime, highlight all and Edit > Line > ReIndent.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
        <string>Indentation Rules</string>
        <string>text.tex, sources.bib</string>
            |   ^\s*\\\].*$
            |   ^\s*\}.*
            |   ^\s*\%.*\(end\).*$
            |   ^.*\\\[\s*$
            |   ^.*\\(.+)\{$
            |   ^\s*\\((sub)[0,2])?section(\*)?\{.*\}.*$
  • 1
    Question. I go into my packages folder and I see LaTeXTools. Does this mean that I would use that folder, or create another folder called 'LaTeX' with a subfolder 'Indentation', and a file Rules.tmPreferences? I'm a complete beginner to Latex, I'm not even sure that I'm using the same plugin that will require this config file – Zach Smith Jul 1 '16 at 17:07

Your Answer

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

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