Skip to content

Instantly share code, notes, and snippets.

@AndreasHassing
Created July 10, 2017 13:07
Show Gist options
  • Select an option

  • Save AndreasHassing/a8b023cb0dfa2baf180e4afd3902bafd to your computer and use it in GitHub Desktop.

Select an option

Save AndreasHassing/a8b023cb0dfa2baf180e4afd3902bafd to your computer and use it in GitHub Desktop.
Requires texcount, generates wordcount, charcount without spaces, charcount with spaces and pagecount based on charcount w/spaces (2400/page). Count characters in latex. Count words in latex.
#!/bin/bash
wordcount=$(texcount Main.tex | sed -n 3p | sed 's/[^0-9]*//g')
charcount=$(texcount -char Main.tex | sed -n 3p | sed 's/[^0-9]*//g')
charcountws=$(($charcount + $wordcount))
pages=$(echo "$charcountws 2400" | awk '{printf "%.2f", $1/$2}')
echo 'Wordcount:' $wordcount
echo 'Charcount no spaces:' $charcount
echo 'Charcount w/spaces:' $charcountws
echo 'Pagecount based on charcount:' $pages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment