LaTeX command frequencies

In the previous post I present a bash one-liner to search directories for LaTeX files and count the commands used.

College files

I first tried this out on a directory that included some old files from grad school. I chose this directory because I knew it had a lot of LaTeX files, but I was surprised at the results. Here were the top 10 results:

  1. \Omega
  2. \partial
  3. \bf
  4. \in
  5. \mu
  6. \real
  7. \int
  8. \item
  9. \alpha
  10. \end

I was very surprised that the top command was \Omega. I expected maybe the integral command \int would come out on top.

The notes contain a lot of integrals, but these integrals were often over a domain Ω. The set inclusion command \in also appears frequently, probably in the context of saying x ∈ Ω.

The \partial came up frequently because I used it in two contexts. First, I was studying partial differential equations, so I used the symbol for partial derivative a lot. Second, I used ∂ to denote the boundary of a domain, as in ∂Ω.

You might notice that \end made the list above but \begin didn’t. Sounds like an error if LaTeX files have more \end statements than \begin statements. The reason is that I used to have an include file that had lots of macros and ended with \begin{document}. That saved a few keystrokes, but now I think such asymmetry is bad form. In the search described below, there are exactly the same number of \begin and \end statements.

Client files

When I looked at the command frequencies in a directory containing some client work, I got very different frequencies. Here were the top commands in that directory.

  1. \hline
  2. \item
  3. \end
  4. \begin
  5. \frac
  6. \xi
  7. \phi
  8. \lambda
  9. \texttt
  10. \partial

I suppose \hline is at the top because the files contained a lot of tables. It makes sense that \item, \begin, \end and \frac were near the top because those are common LaTeX commands. I don’t remember what I was working on that used the symbol ξ so much.

When I first thought about this post I thought I could get a feel for what commands are used frequently in LaTeX in general. I started with my own files because they’re at hand, but the results say more about my usage of LaTeX than about LaTeX in general.

Other collections

I imagine if you were to look at the frequency statistics for a large corpus, such as the articles submitted to a given math journal, the results would still depend somewhat on the journal: you’re going to see \int for integral more often in an analysis journalthan in an algebra journal, etc.

If you run the code from the previous post on some collection of LaTeX files and get some interesting results, leave a comment describing what you found.

More LaTeX posts

One thought on “LaTeX command frequencies

Leave a Reply

Your email address will not be published. Required fields are marked *