# What is the advantage of using the notation 'fig:' in the \label {}?

Reading manuals I always find figure labeled as \label{fig:name}. I wonder where is the advantage of using this notation with fig:instead to start with the name it self. If in my document I have only figures when I \ref something using the label without fig: is more quick because I don't have to type fig: before to find the right figure that I want. Is there any advantage I'm missing? Should I use fig:?

-
If you have sure that you will only have labels for figures you don't need fig:. But in other cases, it is very recommended since you can quickly find the figure labels or table labels or section labels and so on... –  Sigur Jan 2 at 22:41
@Sigur thanks ok so however is arbitrary if I use f is the same thing... –  G M Jan 2 at 22:43
@GM Labels are completely arbitrary (as long as they consist of ASCII characters only). However a personal naming scheme is surely good: with several internal cross references it becomes difficult to keep track of them and some helper is useful. –  egreg Jan 2 at 22:47
In fact it's a convention that is useful for know what object are you making a reference (usually you put a lebel only in the objects you want to refer later). So if you have a lot of labels to diferents objects, is useful the convention {IDobject: object name}. –  Aradnix Jan 3 at 1:01
I usually put '.fig' at the end of the label instead of 'fig:' at the beginning. The reason being that half the time, by the time I've typed "\ref{fig:", I've forgotten what the label name is. –  Nathaniel Jan 3 at 2:06

Here are at least two reasons:

• It expresses the meaning of the label in a very sensible way, in all the below cases the intent of the label is straightforward and it will also let you group things that have meaning to each other, fig:system and eq:system have the meaning of system and one is a figure, the other an equation.

• fig: for figures
• tbl:/tabl: for tables
• eq: for equations
• chap:/chp: for chapters
• sec: for sections
• It can typically be parsed by your editor to easier lookup only figure/table/equation labels. In the case of emacs there is RefTeX which eases the cross-reference system. Several other editors also have such instances of cross-reference system.

-

In addition to the reasons given by others (intelligibility of source; leveraging editor capabilities etc.), if you use fancyref, you can automate more descriptive cross-referencing. This makes it easy to ensure that your cross-references are consistently formatted throughout the document. The system can be adapted to use your own preferred prefixes and labels, and can be extended to cover cross-references to other elements of your document. It can handle both plain and vario referencing and offers upper and lower case referencing commands out of the box.

\documentclass{article}
\usepackage{fancyref}

\begin{document}

\section{A section}\label{sec:mysec}

\begin{figure}
\centering \fbox{A figure}
\caption{My figure}\label{fig:myfig}
\end{figure}

\Fref{sec:myothersec} will demonstrate that \fref{fig:myfig} is fantastic.

\section{Another section}\label{sec:myothersec}

\Fref{fig:myfig} showed whatever my figure showed in \fref{sec:mysec}.

\end{document}


-
cleveref provides a similar functionality without the need of identifiers like fig:. But using them is still a good idea … –  Tobi Jan 3 at 1:48
cleveref looks really nice. Not so much because of the automated identification (though it does rather undercut my answer here!) but because it promises to automatically compress multiple references which is something I've wished fancyref could do. I will definitely have to take a look. I'm guessing you are the author? Thanks! (Though I guess I would lose my current config which is definitely a disincentive!) –  cfr Jan 3 at 2:01
No no … I’m just a user of the package :-) –  Tobi Jan 3 at 2:05
Ah, well. Thanks for the pointer in any case. I notice now that he spells his name with a y not an i. –  cfr Jan 3 at 2:06
Oh … I never noticed that the author has nearly the same name :-) –  Tobi Jan 3 at 2:11

Personally I have never used such a convention (and LaTeX doesn't assume any structure to the labels) the label string is really just an opaque internal identifier. If you find it convenient to give a common prefix to labels of similar objects then do so, but it is certainly not a requirement of the system. Some packages and/or editors may try to parse the structure of the labels and look for fig: etc, but probably they shouldn't.

-

I'm currently writing some lecture notes for "Geometry and Topology" (in German). With that project I've learned why namespaces for labels make sense.

Avoid double labels: I have had problems without prefixes like fig: and sec: or bsp: (for examples) or thm:, because of double labels. Quite often, I have had a figure I want to reference and a theorem. Namespaces solve that problem nicely.

Avoid mix-ups: Sometimes, I wanted to reference sections. So I was sure the section had a label, e.g. \label{lifting}. But in fact, that label was chosen for a figure. This would not have happened when I had prefixes. With prefixes, LaTeX would produce some ?? and make it obvious that I made an error.

After I have seen the screenshot from above, I think there is another advantage for you:

Autocompletion: I guess most of the time you know if you want to reference a figure, a section, a table or whatever. This way, you reduce the number of elements you actually need to think about quite a lot. (By the way, what editor do you use? I still type my LaTeX with gEdit / pluma mot of the time ... maybe you have a better alternative?)

Cleveref and Fancref: There are some reasons why you should use \usepackage{cleveref} (see long answer). With that, you can do something like

\usepackage[nameinlink]{cleveref}
...
As you can see in \cref{sec:abc} ...


which might translate to

 As you can see in section 7


where "section 7" is linked. Additionally, you can pass language options to cleveref which might make translation easier.

So there are some important reasons for using your own convention for label-namespaces.

Collaboration is the only reason for using a "well known namespace scheme" like fig: for figures and sec: for sections.

However, LaTeX doesn't care about label namespaces. They are just a part of the name of the label.

-
It's texmaker with different colors...In mac I use texmaker in Windows texstudio. They are more easy to use rather Vim or emacs with their latex plugin (or gedit but I never tried his latex plugin). –  G M Jan 8 at 22:09