4

I am running Windows 7 and a recent (Dec 2014) distribution of TeX Live and a recent version of TeXmaker.

When invoking arara myFile.tex in the command line it returns "indent SUCCESS" and when opening myFile.tex it is indeed beautified/correctly indented.

However when setting up a macro in TeXmaker (via Users->Commands->User-defined "arara %.tex") TeXmaker returns:

Process started

Process exited normally

However the code is not beautified. Closing and opening the file does not help.

Do you have any ideas on how to make this work?

PS a minimal working example (working from command line - but not via TeXmaker) is:

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

\documentclass[10pt]{article}
\begin{document}
\begin{enumerate}
        \item a
    \item b
\end{enumerate}
\end{document}

PPS indent.log file output (when invoking via TeXmaker)

Thu Dec 11 15:41:00 2014

latexindent.pl version 2.0R, a script to indent .tex files

latexindent.pl lives here: C:/texlive/2014/bin/win32/

>

Directory for backup files and indent.log: .

file: tikpkzTEST.tex Reading defaultSettings.yaml from C:/texlive/2014/bin/win32/defaultSettings.yaml

Home directory is C:/Users/Björn To specify user settings you would put indentconfig.yaml here: C:/Users/Björn/indentconfig.yaml

Backup procedure: (...various backups...) Overwriting file: tikpkzTEST.tex

Line Count of tikpkzTEST.tex: 10 Line Count of indented tikpkzTEST.tex: 10

Line counts of original file and indented file match

PPPS arara.log file

11 Dec 2014 18:50:09.524 INFO Arara - Welcome to arara!

11 Dec 2014 18:50:09.524 INFO Arara - Processing file 'tikpkzTEST.tex', please wait.

11 Dec 2014 18:50:09.524 INFO DirectiveExtractor - Reading directives from

tikpkzTEST.tex.

11 Dec 2014 18:50:09.524 TRACE DirectiveExtractor - Directive found in line 1 with indent.

11 Dec 2014 18:50:09.524 TRACE DirectiveExtractor - Directive found in line 2 with indent: {overwrite: yes}.

11 Dec 2014 18:50:09.584 INFO DirectiveParser - Parsing directives.

11 Dec 2014 18:50:09.584 INFO TaskDeployer - Deploying tasks into commands.

11 Dec 2014 18:50:09.584 TRACE TaskDeployer - Task 'indent' found in >'C:\texlive\2014\texmf-dist\scripts\arara\rules'.

11 Dec 2014 18:50:09.728 TRACE TaskDeployer - Task 'indent' found in 'C:\texlive\2014\texmf-dist\scripts\arara\rules'.

11 Dec 2014 18:50:09.738 INFO CommandTrigger - Ready to run commands.

11 Dec 2014 18:50:09.738 INFO CommandTrigger - Running 'Indent'.

11 Dec 2014 18:50:09.738 TRACE CommandTrigger - Command: cmd /c latexindent.exe "tikpkzTEST.tex"

11 Dec 2014 18:50:10.048 TRACE CommandTrigger - Output logging:

11 Dec 2014 18:50:10.048 TRACE CommandTrigger - % arara: indent

% arara: indent: {overwrite: yes}

\documentclass[10pt]{article} \begin{document} \begin{enumerate} \item a \item b \item c \end{enumerate} \end{document} 11 Dec 2014 18:50:10.048 INFO CommandTrigger - 'Indent' was successfully executed. 11 Dec 2014 18:50:10.048 INFO CommandTrigger - Running 'Indent'. 11 Dec 2014 18:50:10.048 TRACE CommandTrigger - Command: cmd /c latexindent.exe -w >"tikpkzTEST.tex" 11 Dec 2014 18:50:10.348 TRACE CommandTrigger - Output logging: 11 Dec 2014 18:50:10.348 TRACE CommandTrigger - % arara: indent % arara: indent: {overwrite: yes}

\documentclass[10pt]{article}

\begin{document}

\begin{enumerate}

\item a

\item b

\item c

\end{enumerate}

\end{document}

11 Dec 2014 18:50:10.348 INFO CommandTrigger - 'Indent' was successfully executed.

11 Dec 2014 18:50:10.348 INFO CommandTrigger - All commands were successfully executed.

11 Dec 2014 18:50:10.348 INFO Arara - Done.

Björn
  • 41
  • I'm not sure what you want with arara but you can indent your code using the TeXmaker menu, or not? – Sigur Dec 11 '14 at 13:46
  • 1
    @Sigur indent is a nice tool for automatic code indentation (latexindent from cmhughes). I do not think that TeXmaker is able to do such work. – LaRiFaRi Dec 11 '14 at 13:49
  • latexindent is a perl script which can be used via arara. A minimal working example is:% arara: indent % arara: indent: {overwrite: yes}

    \documentclass[10pt]{article} \pagestyle{empty} \begin{document} \begin{enumerate} \item sahddjhhsv \item asdasdfasdf \end{enumerate} fcaf dfgdddsaf \end{document} Texmaker can not autoindent code, so I was trying this workaround. As said; arara correctly indents the code from the command line, but not from TeXmaker.

    – Björn Dec 11 '14 at 13:51
  • 1
    does the editor lock the file for writing? that is while the file is in texmaker can you edit it with anything (eg notepad) if it is locked then the perl script won't be able to edit it. – David Carlisle Dec 11 '14 at 14:06
  • No, when the file is opened with TeXmaker, you can still run arara myFile.tex. TexMaker then opens a window reading "the file your are working with has been changed. do you wish to apply those changes?" when clicking "yes" the indentation is visible in TeXmaker. – Björn Dec 11 '14 at 14:12
  • 1
    There will be indent.log file in that directory. What does that say? –  Dec 11 '14 at 14:29
  • The log file is changed when invoking via TeXmaker. It looks the same (as far as I can tell) if I use the command line. I will append it to the original post. – Björn Dec 11 '14 at 14:46
  • Maybe you need to reload the file. – Sigur Dec 11 '14 at 15:18
  • Reloading does not help. If the tex-file is changed externally TeXmaker notifies it happend. It does not notify when using the arara-command. When closing and reopening after using the arara-command the file is still unchanged and not beautified. – Björn Dec 11 '14 at 15:52
  • Any suggestions for an alternative editor, that plays better with arara/latexindent? – Björn Dec 11 '14 at 15:52
  • @Björn do you just want to indent the code with texmaker and then run arara for automation or do simultaneously ? could you run arara with this flags in user command of texmaker arara %.tex --verbose --log to know what the arara.log says – texenthusiast Dec 11 '14 at 16:18
  • I set texmaker up so that F1 does runs pdflatex and shows the pdf. The command is invoked via ALT+SHIFT+F1 which I want to result in indented code. – Björn Dec 11 '14 at 17:45
  • The the arara-log-file seems fine (generated via texmaker). It shows the correct intendation (which does not transfer to texmaker). I will put the .log in the original post under PPPS. – Björn Dec 11 '14 at 17:52
  • I'll install TeXmaker later on and try to reproduce your issue. :) – Paulo Cereda Dec 11 '14 at 18:50
  • I suspect arara is working, but TeXmaker is not aware of changes in the current file. I'll take a closer look. – Paulo Cereda Dec 12 '14 at 06:46
  • It's nice to see latexindent.pl being used :) It's a good sign that it works from the command line. You only need one arara directive for latexindent; in your MWE you have two directives--the first doesn't overwrite your source, the second does. I'll have a look at this as well--I haven't used TeXmaker before... – cmhughes Dec 12 '14 at 15:32
  • @cmhughes may be TeXmaker checks for external changes based on time stamps of file, I think with texmaker user command latexindent -w %.tex Texmaker does not detect the new file changes but latexident works fine and file is indented well. IMO Check for external changes works only if the file had been modified outside TeXmaker enviroment eg: like a command line interface how Bjorn tried. I don't know if TeXmaker check for external changes need to corrected or fool the texmaker by latexindent file overwriting process. – texenthusiast Dec 12 '14 at 16:15
  • I also tried to get latexindent to work via command-line (embedded in TeXmaker) with the same (non)-result. – Björn Dec 12 '14 at 19:35
  • @cmhughes while testing on my windows 8 I receive this error Can't locate YAML/Tiny.pm in @INC (you may need to install the YAML::Tiny module) (@INC contains:C:/texlive/2014/tlpkg/tlperl/lib c:/texlive/2014/tlpkg/tlperl/lib .) at c:/texlive/2014/texmf-dist/scripts/latexindent/latexindent.pl line 20. when i run at command window latexindent, Is there something i am doing wrong ? any workarounds ? – texenthusiast Dec 12 '14 at 22:58
  • @texenthusiast you need to use your perl distribution to install yaml::tiny. Once you've done that, all should be good :) – cmhughes Dec 12 '14 at 23:27
  • @cmhughes the error persists even with installing YAML::Tiny and other needed modules for latexindent via CPAN in strawberry perl 64 bit win8. helloworld.pl runs well. perl latexindent.pl works well when run from the TL 2014 scripts directory. for some reason latexindent.exe does not work and throws me above error. I think perl need not be installed as perl lib come packaged with TeXLive(may be it misses YAML::Tiny module). so latexindent.exe should work right without a strawberry perl installed ? – texenthusiast Dec 13 '14 at 06:25
  • My Guess is TeXlive tlperl directory is missing the needed modules for execution of latexindent.exe also see related thread . It's fixed in texlive extra pacakges for debian/ubuntu not for vanilla may be. IMO If TeXLive perl has basic restricted modules that only help tlmgr working, then latexindent.exe should not try searching for modules in TeXLive tlperl folder and it should rather look for strawberry perl path and with proper syncing of perl version modules. – texenthusiast Dec 13 '14 at 06:53
  • 1
    @cmhughes So Finally this workaround worked for me. copy entire YAML folder with Tiny.pm from C:\Strawberry\perl\site\lib to C:\texlive\2014\tlpkg\tlperl\lib and any missing File:HomeDir modules from strawberry perl lib (similar version of perl in TeXLive ) to tlperl lib folder then latexindent.exe should fine. BTW IMO Bjorn Error of not updating the .tex file after latexindent in usercommand may be an issue pertaining to TeXmaker editor not arara or latexindent. Bjorn may be you post this issue tracker – texenthusiast Dec 13 '14 at 15:44
  • @texenthusiast thanks for the updates; I certainly agree that the module implementation isn't ideal--I think I need to make latexindent.pl choose the appropriate modules from the distribution, not from tlperl. – cmhughes Dec 13 '14 at 18:09
  • @Björn workaround: In TeXmaker File menu press Reload Document from file to see updated the current file with indented contents. For me latexindent.exe works from commandline and texmaker detects the file changes automatically and it prompts for a option "Document has changed outside of Texmaker do wish to reload the documents with changes have it overwritten etc..". Note you may use Add Path in Options-->Configure TeXmaker to give texmaker user commands to access any binary paths of strawberry perl. Also you may execute external commands using Tools menu -->Open Terminal – texenthusiast Dec 13 '14 at 18:52
  • thanks everyone for looking into it. The workaround posted by @texenthusiast is working for me. (via latexindent.exe I also have to "Reload Document from file" to make it work). I will post to the issue tracker of TeXmaker about the "no-auto-update if changed via texmaker"-issue and mark this question as answered. – Björn Dec 14 '14 at 09:05
  • @texenthusiast I believe that v2.1R of latexindent should now work more smoothly on TeXLive for Windows. As you probably know, TL2014 is frozen, but it should be part of TL2015. If you'd like to grab it manually, you can get latexindent.exe from https://github.com/cmhughes/latexindent.pl; by using the standalone executable, there shouldn't be any need to tangle with perl distributions.... hopefully – cmhughes Jun 05 '15 at 14:54

1 Answers1

2

@texenthusiast has found a workaround for the problem:

In TeXmaker File menu press Reload Document from file to see updated the current file with indented contents.

So basicly you can set up arara/the command-line-version of latexindent to indent the code via TeXmaker:

(*) (Users->Commands->User-defined "arara %.tex" or "texmaker.exe" -w %.tex) or alternatively via (Options->quickbuild->...)

A minor inconvenience remains however: You will have to invoke latex-indent via ALT+SHIFT+F1 (as set up in (*)) and then you will additionaly have to choose "reload document" from the file menu. This should be good enough for most users.

BjörnK
  • 73
  • Nice answer, glad you were able to work through it. If you're on Windows, you might also like TeXnicCenter or NotePad++ which reload the file automatically and ask for a simple confirmation from the user :) – cmhughes Dec 15 '14 at 17:15