4

We usually use \label for a section, equation, figure or table so that we can refer to it in the sequel of the text. I usually use a systematic way for labeling my environments for example

\label{sec:12}
\label{eq:1}
\label{fig:3}
\label{tab:7}

However, when the text becomes long and longer remembering those numbers will be difficult. Specially, when I displace some texts in the editor then the order of the numbering of labels is ruined and it is really annoying. So here are my questions

  • Is there a better strategy for labeling?
  • Is it possible to create an automatic labeling system for an environment?
5
  • 6
    best strategy is never to use numbers in labels. Dec 1, 2016 at 22:31
  • @DavidCarlisle I use counters, but that is probably a bit of a special use case. (Usually, I don't use numbers.)
    – cfr
    Dec 1, 2016 at 22:54
  • @cfr: Would you please give us an example with the counters. :) Dec 1, 2016 at 22:59
  • @cfr: That would be really nice if you write an answer about the usage of counters and making a comparison with descriptive naming. :) Dec 1, 2016 at 23:00
  • I don't think it would be helpful. It is rather a niche use-case. In my case, the counters merely ensure uniqueness for LaTeX's purposes. I don't need uniqueness for human purposes. If LaTeX didn't want globally unique labels, I wouldn't need the counters at all.
    – cfr
    Dec 1, 2016 at 23:28

1 Answer 1

10

Usually you should give labels that reflect the content or purpose of the thing you are labeling. So for instance, instead of \label{eq:1}, say \label{eq:functional_equation} or \label{eq:what_this_equation_does}. The whole point of labels rather than just writing the equation number directly into the document is that you might later add more equations before the current one, which shifts all of the equation numbers forward by one. Then you'll have an equation numbered 2 that you will have to refer to by \ref{eq:1}, which would be unfortunate.

6
  • (+1) Thanks for your attention. I mentioned the issue you said in my question, however, finding descriptive names for large number of equations is not that much easy! :) Dec 1, 2016 at 22:23
  • 5
    @H.R. you only need to label an equation when you reference it and it's usually easy enough to think of an internal label name at that point. Dec 1, 2016 at 22:32
  • @DavidCarlisle: Thanks for the advice David. :) So you suggest using descriptive names!? There are lots of figures, tables, equations and sections! :) Anyway, you are the man of experience and I will take it. :) Dec 1, 2016 at 22:45
  • 4
    @H.R. There is no reason you can't divide each kind into sub-kinds e.g. fig:grph:whatever or fig:photo:whatever or fig:photo:person:whatever. Whatever makes sense.
    – cfr
    Dec 1, 2016 at 22:56
  • @cfr: Is it possible to create an automatic labeling system (descriptive or numeric), specially for equations? :) Dec 2, 2016 at 12:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .