Hi! I’m not sure where the month went, but somehow it’s time for another issue of this newsletter. Welcome!
This month I have a short tip on improving the word count that Overleaf provides as well as an update on my LaTeX for Academic Editors course.
Course Update
The big update is that I have a launch date picked: I plan to open the LaTeX for Academic Editors course on Monday, June 26th. This will be a rolling launch with new lessons being added every few days. I’ll be sending out a coupon code to this list as we get closer.
Improving Overleaf’s Word Count
Many editors, including me, rely on word counts for their quotes. But, getting an accurate word count for LaTeX isn’t straightforward. We can export the PDF to Word, as I described in the first issue of this newsletter, but that will almost certainly overcount the words: every table entry and equation term and sometimes even pieces of figures get counted.
Overleaf has a word count option on its editor menu. The count it provides excludes things like section headings, captions, and footnotes. For some documents, that can significantly undercount the words. I’m going to describe two methods to improve on the word count you can get from Overleaf. The first will just add in footnotes. The second is a bit more flexible and adds in section headings, captions, and footnotes.
Before doing either of these, make a copy of the project and do this work in the copy. We’ll be modifying the document, and you probably don’t want to make these kind of changes in the client’s copy of the project.
Including Footnotes in the Word Count
By default, the utility that Overleaf uses for the word count does not include footnotes and captions. There’s a fairly easy solution for footnotes. In LaTeX, a footnote looks like \footnote{this is a footnote.}
. What we need to do is get rid of the footnote command. We can leave the braces.
So, in your copy of the project, do a global search and replace to change \footnote
to the empty string. Use the Replace All option.
That will change \footnote{this is a footnote.}
to {this is a footnote.}
Note that if your document includes other files with \include
or \input
, you’ll need to run this search and replace for all included files before you run the word count.
Recompile the project, and choose the word count option again. That count will now include footnotes. You can click in the document and do Ctrl-Z (Cmd-Z on Macs) to undo the global replace, but that may not work if you’ve had to update multiple LaTeX files, hence the importance of working in a copy of the project.
Including Captions, Headings, and Footnotes
To include table and figure captions and section headings as well as the footnotes, we have to take a different approach. Building on an example from Overleaf’s documentation, we can run the TeXcount utility directly from the LaTeX document. We’ll give some extra command-line options to TeXcount.
Again, If you’re working with a client’s manuscript, do this with a copy of the project, not the original.
In the preamble, before the \begin{document}
command, insert this block of code:
\usepackage{verbatim}
\newcommand{\detailtexcount}[1]{ %
\immediate\write18{texcount -merge -sum #1.tex > #1.wcdetail }%
\verbatiminput{#1.wcdetail}%
}
Then, right after the \begin{document}
, insert this command:
\detailtexcount{main}
But change “main” to be the name of the top-level LaTeX file.
Recompile the project, and at the top of the document will be a report like this:
“Sum count” is the total number of words it found. “Word in text” matches what Overleaf’s default word count shows. “Words in headers” is the number of words in section headers, and “Words outside text” reports the words in captions and footnotes. The report also shows the number of headers, floats, and math structures.
What we have so far does not include words in table cells. I don’t include these in my word counts, but if you do, there’s a way to tell TeXcount to look in the table and tabular environments. Borrowing again from Overleaf’s help, paste the following comments in the document’s preamble:
%TC:envir table 0 1
%TC:envir tabular 1 1
Recompile the document, and TeXcount’s report will now include words in tables in the “Words in text” count.
As an added bonus, we can add the option “-freq” to the TeXcount command:
\usepackage{verbatim}
\newcommand{\detailtexcount}[1]{ %
\immediate\write18{texcount -merge -sum -freq #1.tex > #1.wcdetail }%
\verbatiminput{#1.wcdetail}%
}
That will add a word frequency breakdown to the report, which is useful for spotting overused words and misspellings.
References:
Wrapping up
And that’s it for this month. Thank you for reading. If you received this newsletter from a colleague, you’re welcome to subscribe — it’s free. And, please pass this letter on to anyone you think may be interested. If you want to catch up on previous issues, you can find them here.
If you’re interested in booking my editing services, you can reach me at wes@wordsbywes.ink or fill out my project information form to let me know what you need.
Till next time…
Wes