10

I study physics and use LaTeX to typeset math-heavy writing. While I can write LaTeX fairly quickly, I often find myself spending too much time on thinking of reasonable names for my equation labels.

I have recognized a few distinct problems regarding this. First of all, I often find it difficult to give my equations succinct, yet descriptive names. This gets especially difficult when I have multiple variants on some sort of equation. So I might have an equation named "GeneralizedAction", but also one named "GeneralizedActionWithEvolutionParameter" and another one named "GeneralizedActionWithKinematicalVariables". It can get fairly ridiculous after a while.

Another problem is that some equations are just difficult to name. This happens often when taking notes, for example, where the exposition isn't thought out in advance as much. The equations here often do not have an obvious name, but mathematical derivations can require extensive referencing of said equations. The problem compounds when the notes are grown, step by step. A name that seems obvious at the beginning can get in the way later on.

I'm sure I can't be the only one being confronted with this problem, but I can find little to nothing about this specific issue. How do you manage your label names?

lockstep
  • 250,273
vosov
  • 235
  • 1
    "How do you manage your label names?" Blood, sweat, and tears. I look forward to learning a better way. – Steven B. Segletes Feb 13 '15 at 20:39
  • This may help while writing; turn it off for production. http://tex.stackexchange.com/questions/45634/printing-labels-along-with-equation-numbers – Ethan Bolker Feb 13 '15 at 20:43
  • If you use TeXstudio, just hold on mouse over some \label{} to see the source code for that. So this could help you to identify the equation. – Sigur Feb 14 '15 at 00:12
  • I should perhaps point out that I use emacs with auctex, reftex and preview-latex, so referring to labels is not an issue. I am specifically asking for label naming strategies. – vosov Feb 14 '15 at 13:23

1 Answers1

3

I don't know whether it's the best strategy but at the moment I am not that unhappy with it. Basically I stick with the thoughts of Robert Martin in his book "Code Complete". He states that code is supposed to explain itself to get rid of comments and such. He forces the reader to use variable names that are long, but explain the everything that one has to know regarding the variable (use, reason, etc.). So my naming strategy is to do some sort of hierarchical extensive naming. Since most modern IDEs support text completion and others even keep lists of labels you don't have to type the labels fully when referencing wihtin the document. From document to document I use other specific hierarchic schemes, but I try to keep a form like this

label(eq:topicA:equationDescriptiveIdentifier:ArbitrarilyChosen:ButVerySpecific)

Hierarchic levels are made up by colons. One hierarchic level is lower CamelCase named. I have to admit, that later on during writing there might be a change in the hierarchy. This is definitely the weak point of this approach.

Using an IDE like TexStudio the usage of labels and references is quite good in my opinion. Like Sigur commented, this IDE also has the option to get a sneak peek of the relevant code without scrolling within the code. Also I use showkeys package as well for drafting the document.

goeck
  • 216
  • I like your strategy! It never occurred to me to extend the hierarchy of the labels. It seems to be flexible enough to be usable for both articles and notes, so it solves both my problems. I can imagine writing some functions for emacs to refactor the hierarchies, which would make it even more convenient. – vosov Feb 15 '15 at 18:01
  • Having a refector method for changing the hierarchy levels later on would be a nice to have, I have to admit. One could also actually do this by find&replace using beginning and ending double dots. Still working on a better strategy though... – goeck Feb 15 '15 at 18:03