1

My coauthors and I are tasked with reducing the word count of our paper. We're beginning by highlighting text with the soul package. But what we'd like to know is how many words are contained in the highlighted sections of text, in order to decide yes or no on cutting that portion.

I know how to get word counts for the document as a whole via the online sites, but this is different: word counts for highlighted text.

bshor
  • 287
  • 2
  • 9

1 Answers1

2

TeXcount to the rescue:

mwe

Source:

\documentclass{article}
\usepackage{soul}
\usepackage{moreverb}
\immediate\write18{texcount  \jobname.tex > /tmp/hlcount.tex}
\def\hlcount{\bigskip\hrule\bigskip\verbatiminput{/tmp/hlcount.tex}\hrule}
\begin{document}
Some long text to test.
%TC:break highlighted text
\hl{Some highlighted text that must be counted.}
%TC:break plain text
Some other long text.
%TC:break more highlighted text
\hl{Some other highlighted text that also must be counted.}
%TC:break more plain text
One more long ending  text.
\hlcount
\end{document}

Compiled it with pdflatex --shell-escape filename

Fran
  • 80,769
  • I'm on Windows so /tmp/hlcount.tex fails. Also does this require Perl to be installed? – bshor May 17 '16 at 21:55
  • Of course, on Windows yo should change /tmp/hlcount.tex to to some like c:\temp\whaterver.tex and install Perl. – Fran May 18 '16 at 06:57