10

I guess that I have overlooked something, but I can't find a solution to run arara on my subfiles when processing my main file. I would like to autoindent my code but only succeed for the main.tex.

I installed latexindent.plx which works great. If I run % arara: indent: { overwrite : yes } on a single file document, everything works like expected.

In my actual documents the main.tex will look like this:

% arara: lualatex: { shell: yes }
% arara: indent: { overwrite : yes }
% arara: indent: { trace : yes }
\input{header}
\begin{document}
\include{chapter/foo}
\end{document}

For this solution, I get main.tex indented beautifully but not the header and not the chapters. As arara is looking for commands all over the source, I added another % arara: indent: { overwrite : yes } on top of some subfiles, but they don't effect the process. I would be glad for a hint, where my thinking error is.

  • 1
    This is the first latexindent question- thanks very much for trying it :) I'll do some experiments and get back to you, I have an idea on what to try :) – cmhughes Aug 8 '13 at 12:39
9

First of all, thanks very much for trying latexindent :)

Your question is pretty much exactly the same idea as arara: making a rule to compile the main file from a chapter file and the trick is to tell arara which files you want to operate on.

As such, the following works as you want.

% arara: indent: { overwrite : yes, trace: yes, files: [ chapter/foo.tex, header.tex, chapter/bar.tex ]  }
\input{header}
\begin{document}
\include{chapter/foo}
\end{document}

Note that I have combined your two arara indent directives into one, otherwise you're running it twice- this shouldn't be necessary, and should probably be avoided. If latexindent does something wrong on the first pass, then the trace would have told you what happened on the second pass, which wouldn't have been very useful.

| improve this answer | |
  • oh that's cool. And beautiful. Works great. Nice feature would be to select all files (or even synced to \includeonly) but at first, it gives good control. main.tex is not indented now so that the annoying "file changed outside your IDE" is not appearing for all files but the selected ones. – LaRiFaRi Aug 8 '13 at 13:17
  • For a cool "let me indent all your source code for you with the cool tool I found", this solution is a bit unwieldy. I am just thinking of all my .tikz and mydefs.tex-files... – LaRiFaRi Aug 8 '13 at 13:27
  • @LaRiFaRi glad it worked. You can certainly run latexindent on a list of files- it sounds like you might need to write a batch script of some kind, which will vary depending on your operating system – cmhughes Aug 8 '13 at 14:57
  • 1
    If it can help someone: the following code applies latexindent to all tex files of the current directory, on a Linux shell: find . -name '*.tex' -exec latexindent -w $1 -- {} \;. – anderstood May 3 '17 at 1:16
  • 1
    No problem :) feel free to contact me at GitHub if ever you'd like to chat about latexindent:) – cmhughes Aug 12 '17 at 19:29

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.