Articles LaTeX word count

Word Count in LaTeX: A Practical Guide with texcount

A practical guide to LaTeX word counting with texcount: the flags to run, %TC directives for custom macros, editor and CI integration, and matching journal or thesis limits.

inscrive.io · Jan 30, 2025 · 8 min read
Word Count in LaTeX: A Practical Guide with texcount

Word Count in LaTeX: A Practical Guide with texcount

You hit submit on a paper and the portal rejects it: 8,214 words against an 8,000 limit. In a word processor you would have seen that coming. LaTeX hides the number, because your .tex file is full of markup that isn’t text. This guide is the practical end of LaTeX word counting: the commands you actually run, how to wire them into your editor and build, and how to match the count a journal or thesis office expects. For the conceptual side (why detex, a script, and texcount disagree), see the companion piece on LaTeX word counting methods.

The short version: install texcount, run it, configure a couple of comment directives for your custom macros. Most people never need more.

Why the number is hard to get

A .tex file mixes three things that all look like text to a naive counter. Real prose. Markup such as \section{}, \cite{}, and \ref{}. And math, where $\alpha + \beta$ is two symbols, not two words. Add captions, footnotes, comments, and multi-file projects with \input, and “how many words is this” stops having one answer.

That ambiguity is the whole game. A journal that says “6,000 words excluding references and captions” is describing a counting rule, and your job is to reproduce it. So before counting, find out what the count is supposed to include.

texcount: install it once

texcount is a Perl script that ships with TeX Live and MiKTeX, so if you have a LaTeX install you very likely already have it.

# Check whether it's already there
texcount --version

If it isn’t on your PATH:

# Debian/Ubuntu (TeX Live)
sudo apt-get install texlive-extra-utils

# macOS with MacTeX/Homebrew
brew install texcount

On Windows with MiKTeX or TeX Live it’s installed alongside the distribution. If texcount isn’t found, the binary lives in the distribution’s scripts directory; add that to PATH.

The commands you’ll actually use

Start plain:

texcount thesis.tex

You get a breakdown: words in text, words in headers, words in captions, plus counts of headers, floats, and inline and display math. That separation is the point. A “6,000 words” limit almost always means words in text, not the grand total.

A few flags cover most real needs:

# One-line summary, good for scripts
texcount -brief thesis.tex

# Follow input and include across the whole project
texcount -inc main.tex

# Per-chapter / per-section subcounts
texcount -sub thesis.tex

# Verbose: prints the document with words marked, so you can see
# exactly what it did and didn't count
texcount -v thesis.tex

The -v mode is underrated. When a count looks wrong, run it and read the colour-coded output. You’ll usually spot the culprit immediately, a custom macro swallowing a paragraph, or a caption counted when you wanted it excluded.

Excluding and including the right parts

The decisions a word limit cares about are usually captions, headers, and the bibliography.

# Drop headers and captions from the total
texcount -nosub -sum thesis.tex   # -sum reports a single combined number...
texcount -merge -sum main.tex     # ...and -merge folds input files into one count

# Include the bibliography in the count
texcount -incbib paper.tex

By default texcount counts citation keys, not the rendered bibliography, which is what most limits want. Use -incbib only when a limit explicitly counts the reference list.

Custom macros and environments

Real documents define their own commands, and texcount can’t guess what they do. You teach it with %TC: directives placed as comments in your source. They live in the .tex file, so the rule travels with the document.

% Treat the argument of \keyword as countable text
%TC:macro \keyword [text]

% Ignore a custom \todo note entirely
%TC:macro \todo [ignore]

% Don't count the contents of a solution environment
%TC:envir solution [ignore] ignore

The %TC:envir line takes the environment name, how to handle its arguments, and how to handle its body. ignore for both drops it completely. If your numbers look off by a chunk, an uncounted custom environment is the usual reason.

Math

By default texcount reports inline and display math as separate tallies rather than folding them into the word total, which is the honest default. If a particular journal wants display equations counted as words, you can change that per environment with the same directive syntax.

Matching a specific requirement

Journals

Read the author guidelines, then translate them into flags. A limit that excludes references and captions maps to something like:

texcount -merge -sum -nosub paper.tex

When you report the number, note the method. Editors rarely argue with “6,142 words (texcount, main text, excluding references and captions).”

Theses

University regulations vary, and many count the main body only, excluding front matter, bibliography, and appendices. Split the project so the rule is easy to apply:

# Main chapters, combined
texcount -merge -sum chapter*.tex

# Appendices reported separately
texcount -merge -sum appendix*.tex

If your regulations give a character limit instead of words, texcount -char and -charws (with whitespace) cover both readings.

Wiring it into your workflow

Editor integration

In VS Code with the LaTeX Workshop extension, texcount drives the status-bar count:

{
  "latex-workshop.wordcount.path": "texcount",
  "latex-workshop.wordcount.args": ["-inc", "-merge", "%DOC%"]
}

TeXstudio and TeXmaker have built-in word-count entries that call texcount under the hood, so the same logic applies without configuration.

Build and CI

For a hard limit, fail the build when you exceed it. The -1 flag prints just the number, which is what you want in a script:

#!/bin/bash
LIMIT=8000
COUNT=$(texcount -1 -sum -merge main.tex)
if [ "$COUNT" -gt "$LIMIT" ]; then
  echo "Word count $COUNT exceeds limit of $LIMIT"
  exit 1
fi

Drop that into a Git pre-commit hook or a CI step and you’ll never be surprised by the submission portal again.

Counting without installing anything

If you’re writing in the browser, the count is just there. An online editor parses the document as you type and keeps a running figure, the same way a word processor does. inscrive.io shows a live count and recomputes across a multi-file project on every compile, so the number reflects what \input actually pulls in. Because editing is real-time and collaborative, the figure stays current while several authors work on the same file.

inscrive is freemium: the Free plan (€0, up to 10 active projects, 60-second compiles) is enough for most single papers, and Pro (€7/month) lifts compile time to 480 seconds and adds AI-suggested fixes for compile errors. Documents are stored entirely in the EU (Hetzner data centres in Germany and Finland, ISO 27001 certified), and your work is never used to train AI models. New to the browser workflow? The beginner’s guide to LaTeX is a good starting point, and the online editor comparison covers how the options differ.

A workable default

For most documents this is enough:

texcount -inc -sum -brief main.tex

Add %TC: directives for any custom macro that’s throwing the count off, decide once whether the bibliography is in or out, and write the method down next to your draft. That last habit, recording how you counted, saves more arguments with editors than any flag.

Want the count without the setup? Start writing on inscrive.io for free and watch the word count update as you type, across every file in the project.

Sign up for our newsletter

Roadmap progress, announcements and exclusive discounts — straight to your inbox.

We care about the protection of your data. Read our privacy policy.