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 filesI 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:
- \Omega
- \partial
- \bf
- \in
- \mu
- \real
- \int
- \item
- \alpha
- \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 I(C). The set inclusion command \in also appears frequently, probably in the context of saying x a I(C).
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 a to denote the boundary of a domain, as in aI(C).
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 filesWhen 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.
- \hline
- \item
- \end
- \begin
- \frac
- \xi
- \phi
- \lambda
- \texttt
- \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 I3/4 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 collectionsI 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