Counting words in TeX/LaTeX

I was trying to find an easy way to count the words in LaTeX documents. I guess there must be clients that do this for you, but I don’t use such a client and many times I’m using vi to edit LaTeX documents.

An way to go with it is to use a filter to strip as much as possible the TeX/LaTeX commands from the .tex file. This can be easily done with the detex command and the wc command:

detex report.tex | wc -w

Another way to filter the .tex document is to use untex in the same way as detex. This link describes lists also an alternative way of counting the words by converting the .dvi file to a plain text file:

dvips -o - report.dvi | ps2ascii | wc -w

However, this way doesn’t seem to filter the .dvi file that good so you may count more commands as words.

Advertisement

Basic and generic LaTeX notes

Some basic stuff I came across while writing on LaTeX:

  • Subscript, Greek letters, special character in mathematical form
\begin{center}
\( H_{0} \): ${\mu}$\( _0 \) = ${\mu}$\( _1 \)
\\
\( H_{1} \): ${\mu}$\( _1 \) ${\neq}$ ${\mu}$\( _1 \)
\end{center}
  • Chapters definitions etc
\tableofcontents
\abstract
\chapter{one}
\section{one}
\subsection{one}
\subsubsection{one}
  • Two graphics side by side
\begin{minipage}[b]{0.5\linewidth}
\centering
\includegraphics[scale=0.3] {graphics/figure1}
\caption{{\bf label}}
\end{minipage}
\hspace{0.5cm} % Space between the figures
\begin{minipage}[b]{0.5\linewidth}
\centering
\includegraphics[scale=0.3] {graphics/figure2}
\caption{{\bf label2}}
\end{minipage}
\end{figure}
  • Single image
\begin{figure}[htbp]
\begin{center}
\includegraphics[scale=0.5] {graphics/figure3}
\caption{{\bf label3}}
\label{default}
\end{center}
\end{figure}
  • Bulletpoint list
\begin{itemize}
\item
item1
\item
item2
\item
item 3
\item
item 4
\end{itemize}
  • Text formation: italics

\textit{behaviour}

  • Special characters (such as % and & for instance)

\% \&

  • Plain text format

\texttt{text}