Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

The journal I am submitting to requires a count of the words on the title page. I can of course run texcount on the .tex document and put the number in, but it seems that I should be able to automate this.

For tables and figures (which are also required), I can simply use the totcount package. Is there something equivalent for words? Or can I store the output of texcount in such a way that I can call it on a subsequent pdflatex run?

share|improve this question
    
This is similar in many ways to the request at tex.stackexchange.com/questions/44618/…. I can't see how to adopt this directly, however. –  gmacfarlane Mar 23 '12 at 17:49

2 Answers 2

up vote 12 down vote accepted

Here is the solution using bashful. Note that you need to run latex or pdflatex using -shell-escape option

\documentclass{article}
\usepackage{bashful}
\pagestyle{empty}
\bash
texcount -sum -1 tmp.tex
\END
\begin{document}    
This file has \emph{\bashStdout} words.
\end{document}

:

share|improve this answer
    
I combined your texcount syntax with the macro supplied by Jake on the other question, and it works wonderfully. Yours didn't work because of \bashStdout is not recognized as a control statement. But thanks for helping me with the texcount syntax! –  gmacfarlane Mar 23 '12 at 19:29
    
You probably need to upgrade bashful to get \bashStdout to work –  Boris Mar 23 '12 at 19:38
    
I don't suppose that there is a way to pass the name of the document to texcount automatically? The macro from the other question uses \jobname, but when I tried that here it didn't work. –  Tom Aug 4 '12 at 9:44

Here is a solution that does not require an external package:

 \makeatletter\@@input|"echo `texcount -1 manuscript.tex`| cut -c1-4"\makeatother

The cut command assumes a four digit number and could be parsed more elegantly.

This command requires --shell-escape when compiling, as in:

pdflatex --shell-escape myfile.tex
share|improve this answer
    
I prefer this solution respect to the first one. However, when I use it, it produces an unwanted white space after the four digit number. I worked around that using \hspace{-.5ex} but maybe it depends on the parsing of texcount's output –  Alessandro Cuttin Aug 16 '13 at 10:32
    
BTW, it can be improved as following: \makeatletter\@@input|"echo texcount -q -1 -merge \jobname.tex`| cut -c1-4"\makeatother` –  Alessandro Cuttin Aug 16 '13 at 11:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.