I'm trying to get texcount.pl http://app.uio.no/ifi/texcount/ to work inside Texmaker but I get the error about the word.count that is not found. The documentations says that I have to add --shell-escape to solve the problem but I don't know where to put that. Does anyone know?

  • Just to clearify: Are you trying to run TeXcount from Texmaker as a user command, or are you trying to get TeX/LaTeX to execute TeXcount from within the document so the TeXcount is executed every time the document is typeset? The --shell-escape option is a TeX/LaTeX option required by the latter to be allowed to execute shell commands from within the TeX/LaTeX document. – Einar Rødland Sep 1 '12 at 12:50
  • According to the manual (xm1math.net/texmaker/doc.html#SECTION02) there's "Configure Texmaker" -> "Commands" which brings you to where the LaTeX command (with options) is specified. – Einar Rødland Sep 1 '12 at 12:55
  • I'm trying to get Latex to execute texcount within the document. I currently have this latex -interaction=nonstopmode %.tex in my latex command. Where exactly do I put shell-escape because I tried several places and it gives an error. – user579674 Sep 1 '12 at 14:30
  • You could try "latex -interaction=nonstop --shell-escape %.tex" and if that doesn't work try replacing "--shell-escape" with "--enable-write18". – Einar Rødland Sep 1 '12 at 15:31
  • Should it be nonstopmode or is nonstop what I should put? I tried with nonstopmode and both shell-escape and enable-write18 at the place you suggest but it still returns an error – user579674 Sep 1 '12 at 15:42

To summarise the answer (so far):

Running TeXcount, or any other OS command, from TeX or LaTeX is done by entering code similar to this

\immediate\write18{texcount test.tex > test.sum}

in the TeX/LaTeX document (which I've checked and work when I do it from TeXworks). A somewhat improved version of this is provided on the help pages of TeXcount

\immediate\write18{texcount \jobname.tex -out=\jobname.sum}

provided you have a more recent version of TeXcount. In either case, this requires texcount to be in the path, or the OS will not find it.

TeX and LaTeX (and other TeX versions) will by default not execute \write18 commands unless you give the options --shell-escape (for TeX I believe) or --enable-write18 (for LaTeX I believe).

Changing the LaTeX options is explained in the Texmaker manual.

Note that TeXcount may have slightly different filenames from system to system depending on where you got it from: texcount or texcount.pl, and I know some have also compiled it into texcount.exe.

If it still doesn't work, you should try to figure out which thing goes wrong. Try running LaTeX from the command line instead of Texmaker to see if that works or what errors are given. Or try executing something like dir > dir.txt in the \write18 to see if you can get it to execute at all.

| improve this answer | |

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.