arara
is a cool tool for LaTeX automation, it works by setting your directives (i.e., a code line in tex document) to tell arara what to run next in a specific order that best suits your LaTeX compilation needs. These directives should contain rules (i.e., configuration files that are written in YAML language, default rules ship already with the package but you can create your own) One of the default written rules, called clean
, which I found useful to get rid of the auxillary as well as other files which are normally generated during the process of PDF compilation.
The problem arises, when one is working inside a Dropbox folder (a reasonable way to keep your files in the cloud synchronized, updated, and shared), as arara
is trying to delete these auxiliary, etc.. files by the clean rule, Dropbox is trying to synchronize them, and synchronization will take some time depending on the size of your files, here comes the problem, arara clean rule will fail, reporting that files are used by another program.
One workaround is to add a sleep
command before the delete command in the clean rule file. The below code was generously given from Paulo Cereda, one of the authors of arara
fantastic package:
!config
# requires arara 3.0+
identifier: clean
name: NewCleaningTool
commands:
- <arara> COMMAND HERE @{wait}
- <arara> @{remove}
arguments:
- identifier: remove
default: <arara> @{isFalse(file == getOriginalFile(), isWindows("cmd /c del", "rm -f").concat(' "').concat(file).concat('"'))}
- identifier: wait
flag: <arara> @{parameters.wait}
default: 10
The above code should replace the default clean.yaml file in the arara
rules directory, or a better approach, thankfully suggested by Marco Daniel, one of the authors of arara
package, is to provide a new path in araraconfig.yaml
for the new rule. Directives in tex
file should look like this:
% arara: xelatex: { shell: true }
% arara: makeglossaries
% arara: biber
% arara: xelatex: { shell: true }
% arara: xelatex: { shell: true }
% arara: clean: { wait: 15, files: [phdmain.aux, phdmain.idx, phdmain.glg, phdmain.ilg, phdmain.bbl, phdmain.ind, phdmain.log, phdmain.gls, phdmain.glo, phdmain.bcf, phdmain.blg, phdmain.run.xml, phdmain.lof, phdmain.lot, phdmain.out, phdmain.toc, phdmain.xdy]}
\documentclass[oneside]{scrbook}
\begin{document}
This is just a MWE to show if clean rule of arara package is waiting the specified seconds passed as a wait argument in the clean directive above, the default was set to 10 seconds in the clean.yml file, however if you have large files you might need longer waiting periods until Dropbox is done with syncronization of your files, leaving them ready to be deleted by clean rule directive of arara package. An elegant way to keep your messy tex folder as clean as possible.
\end{document}
Question:
What command should replace the COMMAND HERE
in 6th line of the YAML file above that works in Windows 7 platform?
I tried the following but didn't work:
- <arara> TIMEOUT @{wait}
and also:
- <arara> powershell -command "Start-Sleep -s @{wait}"
Notes:
To comment out arara
directives you can add ! before arara like this:
% !arara: biber
dropbox stop
anddropbox start
). After all one point of the ancillary files is to aid document-creation (easy, I guess, to forget that with today's computers).dropbox
to ignore or filter certain files (.log
,.aux
, etc)- then you wouldn't have to worry about removing them so often. I'm not sure of the precise syntax but it does look possiblearara
: use the-output-directory
directive to letpdflatex
create all files in some temporary directory outside of your dropbox and, if desired, copy just the PDF back.arara
.arara
only executes a command with options ;-)araraconfig.yaml
.