# Using Arara with TexCount

I'm running TeXShop and I have a pretty big document - my PhD thesis. I want to do a word count with regular intervals, not necessarily every time I compile, but I want the information to be accessible if I so choose.

I've installed TeXCount (and the alternative TeXCount300) engines, and I can get them to work just fine.

However, I also use Arara to compile. I've tried changing the arara-commands to:

% arara: pdflatex
% arara: pdflatex
% arara: bibtex
% arara: pdflatex
% arara: texcount


But then I get an error message like this:

"Uh-oh, I could not find the 'texcount' rule in the search path.
Could you take a look if the rule name is correct and if the rule
is accessible through the search path?"


Can anyone help me integrate TeXCount and Arara?

• The "argument" to an arara line is not the name of a binary, it refers to a rule, which is specified in a text file with a specific format, so such a rule has to be made for texcount. Nov 5, 2015 at 21:34
• Hmm, I'm afraid I'm not sure how to do that. Can you point me to where I need to look for the rules?
– CTH
Nov 6, 2015 at 9:10
• The manual describes this I guess, sorry, should have mentioned that above. My comment was just intended as a quick explanation for why arara: texcount didn't work. Nov 6, 2015 at 9:30
• Hi again, OK I've found the rules and tried adding a rule for TeXCount. But no luck getting it to work. Any suggestions on how the rule-file should look? I still can't even get it to recognize that there is a rule-file, I keep getting the same error message as above.
– CTH
Nov 7, 2015 at 7:36
• No, I've never tried to write one myself. I asked someone who should know (the main developer of arara) to take a look, so you might get some better help later. Meanwhile, if you want to bring more attention to your question, you could edit it to include your new rule, and say what you've tried. Nov 7, 2015 at 7:52

I apologize for the late answer.

In order to run a task, arara requires a rule to tell it how to do it, that's why % arara: texcount didn't work. So we need to come up with a rule. :)

A very simple rule to call $texcount mydocument.tex is presented as follows (the file has to be named texcount.yaml in order to work): !config identifier: texcount name: TeXcount command: texcount @{file} arguments: []  It is self-explanatory, I believe. :) No arguments, just a call to texcount with the current file being processed (arara already handles file override with the special files parameter, so we don't need to worry with it in the rule context). Of course, since I have a custom rule, I need to tell arara how to find it. Then I need to create a file named araraconfig.yaml in my home directory (/home/paulo in Unix, C:\Users\Paulo in Windows or /Users/paulo in Mac) and add the rule location to it: !config paths: - /home/paulo/myrulefolder  And we are done! :) Let us try this new rule with a very simple TeX document, named mydoc.tex, presented as follows: % arara: pdflatex % arara: texcount \documentclass{article} \begin{document} Hello world! \end{document}  Running arara mydoc.tex in the terminal gives us the following output: [paulo@cambridge ~]$ arara mydoc.tex
__ _ _ __ __ _ _ __ __ _
/ _ | '__/ _ | '__/ _ |
| (_| | | | (_| | | | (_| |
\__,_|_|  \__,_|_|  \__,_|

Running PDFLaTeX... SUCCESS
Running TeXcount... SUCCESS
[paulo@cambridge ~] $ Uh-oh. Although texcount was successfully executed, I was expecting the command output in order to check the statistics. We could use the --verbose flag in order to tell arara to show what is going on under the hood: [paulo@cambridge ~]$ arara mydoc.tex --verbose
__ _ _ __ __ _ _ __ __ _
/ _ | '__/ _ | '__/ _ |
| (_| | | | (_| | | | (_| |
\__,_|_|  \__,_|_|  \__,_|

Running PDFLaTeX...

This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
(./mydoc.tex
LaTeX2e <2015/10/01> patch level 2
Babel <3.9m> and hyphenation patterns for 79 languages loaded.
(/usr/local/texlive/2015/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2015/texmf-dist/tex/latex/base/size10.clo)) (./mydoc.aux)
[1{/usr/local/texlive/2015/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./mydoc.aux) )</usr/local/texlive/2015/texmf-dist/fonts/type1/public/amsfonts/
cm/cmr10.pfb>
Output written on mydoc.pdf (1 page, 11921 bytes).
Transcript written on mydoc.log.
Status: SUCCESS

Running TeXcount...

File: mydoc.tex
Encoding: ascii
Words in text: 2
Words outside text (captions, etc.): 0
Number of floats/tables/figures: 0
Number of math inlines: 0
Number of math displayed: 0

Status: SUCCESS

[paulo@cambridge ~] $ Well, it worked, but is there a way to nicely show the output instead of this clumsy solution? Now, the sad part: with version 3.0, we might need a bit of trickery in order to make things work. You could read my answer in the following link in order to understand why I cannot exploit rules to do more complex stuff: Arara rule to delete files with wildcard Long story short: version 3.0 evaluates rules beforehand. With version 4.0, arara now relies with a REPL workflow, but it would be unfair to talk about it since I am still writing the manual and the tool is not officially released. I will update this answer accordingly when the new version is out. A potential improvement is to write a wrapper script (in my example, named gtexcount.sh) with the following content (I could also suggest a bash function, as in Is it possible to write an arara rule which uses a bash script?): #!/bin/bash zenity --info --title='TeXcount' --text="$(texcount \"$1\")"  (I am using zenity here, but there are other options available as well) With a quick rule update, we can now invoke this script instead of the original texcount and a nice window will display the file statistics: !config identifier: texcount name: TeXcount command: /home/paulo/gtexcount.sh @{file} arguments: []  (Of course, I also did $ chmod +x gtexcount.sh in order to give it proper execution permission)

Let us try our new rule:

After clicking the OK button, we have everything back to normal:

[paulo@cambridge ~] $arara mydoc.tex __ _ _ __ __ _ _ __ __ _ / _ | '__/ _ | '__/ _ | | (_| | | | (_| | | | (_| | \__,_|_| \__,_|_| \__,_| Running PDFLaTeX... SUCCESS Running TeXcount... SUCCESS [paulo@cambridge ~]$


Not the best solution available, but I believe it is quite acceptable while version 4.0 is not around the block yet. Hope it helps! :)

• @CTH: My pleasure! I apologize for the long delay in replying to your question. Sadly, my PhD thesis is taking me a lot of time and effort. Hopefully, version 4.0 will be out soon. All the best! :)` Jan 4, 2016 at 17:32
• I know the feeling - I submitted mine a week ago! Best regards - Christian
– CTH
Jan 5, 2016 at 18:12
• @PauloCereda now that 4.0 is out, could you update your answer to add out to do it in the new version? Additionally, being able to safe the output of texcount in a file would be great so that we can parse it and include the word count in the source for example. I had a makefile that did that but would be neat to do that in arara. Jul 31, 2018 at 13:34
• @ArTourter: Hi! Sure, I plan to take a closer look at most of arara questions in the site. However, I am a bit busy in this week, so I need to postpone it to the next one. If I forget, please ping me! Jul 31, 2018 at 15:20