Useful LaTeX tricks

Aug 3, 2013

\(\LaTeX\) word count

It can get difficult to keep track of accurate number of words in a \(\LaTeX\) document. TeXcount is a script for counting words in text and math equations in LaTeX documents. It can also generate very detailed html output with color-coded words types. TeXcount is part of Tex live and can be installed by installing texlive-extra-utils from Ubuntu repository. TeXcount also has a web interface. $ texcount document.tex FILE: document.tex Words in text: 6462 Words in headers: 48 Words in float captions: 274 Number of headers: 19 Number of floats: 4 Number of math inlines: 204 Number of math displayed: 8 texcount -v -html document.tex > word_count.html

\(\LaTeX\) diff

Usual diff programs may not do a great job of diffing two \(\LaTeX\) documents. Following are some of the alternative ways:
  • Use wdiff with colordiff, similar to this stackexchange question: wdiff -n old.tex new.tex | colordiff | less -R
  • Use latexdiff to determine differences and create a new LaTeX document with markup differences between two latex files. latexdiff can be found in Ubuntu repository and detailed description of usage can be found here. An example with beautifully typeset document is given below. latexdiff draft.tex revision.tex > diff.tex
  • Another alternative could be to follow a simple guideline: Always start a new sentence in a new line and do not put any line-breaks in till the sentence ends. This allows traditional diff/merge programs like meld etc to work in a much better way.

\(\LaTeX\) and git

It is useful to use a version control system, like git, with \(\LaTeX\) documents. Here are some useful tips while working with git:
  • Check git + LaTeX workflow for some great tips.
  • Use latexdiff (also see above) in smarter way:
    • latexdiff <(git show checksumHash:file.tex) file.tex > diff.tex
    • Git-latexdiff can also be used for more advanced operations, like documents involving multiple .texfiles.
    • Check stackexchange discussion for more solutions.

\(\LaTeX\) on blogspot.com

MathJax is awesome. It is very easy to install and get \(\LaTeX\) equations working. \[ J_\alpha(x) = \sum\limits_{m=0}^\infty \frac{(-1)^m}{m! \, \Gamma(m + \alpha + 1)}{\left({\frac{x}{2}}\right)}^{2 m + \alpha} \]
Read more ...