A Python tool to count character or word contributions of each author in a LaTeX project, based on git blame
.
This is particularly useful for collaborative textbook or research note projects where authorship and writing effort need to be measured quantitatively.
- ✅ Counts by actual authorship using
git blame
- ✅ Supports both words (default) and characters (
--char
) - ✅ Removes LaTeX syntax when requested
- ✅ Reads
.fls
to trace all.tex
files recursively - ✅ Automatically compiles
.tex
with-recorder
if.fls
is missing - ✅ Outputs human-readable table in terminal
- ✅ Logs results to
count_word.log
- ✅ Outputs CSV (
count_word.csv
) for plotting or analysis
Install dependencies:
pip install tabulate
If .fls
file is not found, the script will automatically run xelatex
or pdflatex
twice.
You may also pre-compile manually:
xelatex -recorder main.tex
# or
pdflatex -recorder main.tex
python count_latex_contrib.py main.tex
Flag | Description |
---|---|
--char |
Count characters instead of words |
--nocsv |
Disable output of count_word.csv |
--pdflatex |
Use pdflatex instead of xelatex |
--fls |
Manually specify .fls path |
=== Total Contributions (Without LaTeX Grammar) ===
╒══════════════════╤══════════════╤══════════╕
│ Author │ Characters │ Percent │
╞══════════════════╪══════════════╪══════════╡
│ Photon │ 131025 │ 44.85% │
│ LittlePhoton │ 52291 │ 17.90% │
│ ... │ ... │ ... │
╘══════════════════╧══════════════╧══════════╛
count_word.log
: Plain text result with timestampcount_word.csv
: Optional CSV (Author,Plain,Raw
) for Excel/plotting
MIT License. Use freely, attribution appreciated.
Created by PhotonYan for collaborative academic writing and fair contribution analysis.
Contributions and suggestions welcome!