GNOME Bugzilla – Bug 675344
Simple alteration in the "Insert figure" command
Last modified: 2012-05-03 17:05:40 UTC
When you want to insert a figure, the Latexila "Figure" icon returns the following command lines: \begin{figure} \begin{center} \includegraphics{} \label{fig:} \caption{} \end{center} \end{figure} My suggestion is to permute the 'caption' and the 'label', creating the profile \begin{figure} \begin{center} \includegraphics{} \caption{} \label{fig:} \end{center} \end{figure} It may sound unnecessary, but I found that many 'wrong labeling' errors (e.g., reference a figure as number 2 in a document with only one figure) ocurred because of this ordering. In addition, there could be a '[width = (fraction)\textwidth]' just after the 'includegraphics' to facilitate the definition of the size of the figure in the text. What do you think?
(In reply to comment #0) > It may sound unnecessary, but I found that many 'wrong labeling' errors (e.g., > reference a figure as number 2 in a document with only one figure) ocurred > because of this ordering. Do you have a .tex sample that show this bug? I thought the label refers to the figure environment, but it is possible that the label refers to the previous caption, or something else. Before applying the modification, it would be nice to know why this bug occurs, and knowing what is the best way to include a figure with a caption and a label. > In addition, there could be a '[width = (fraction)\textwidth]' just after the > 'includegraphics' to facilitate the definition of the size of the figure in the > text. What do you think? The plan is to add completion support for the options of \includegraphics. There are a lot of different means to specify the size of the image. I prefer no options at all by default.
Created attachment 213389 [details] Sample with wrong labeling and right labeling of figures and tables. This .zip file contains two folders, both with the sample example. In the first, "Buggy example", the .pdf generated contains wrong labeling of the figure (ftest.pdf) and the table because of the ordering of the \label and \caption. In the second, this order is permuted (puting \caption first), and the references are now o.k.
I put an example in the above comment. I tried several (la)tex editors, and all of them results in the same bug. It seems to happen when you have a text with several sections, chapters etc. I found a solution in the following blog: http://www.terminally-incoherent.com/blog/2007/04/14/latex-fixing-wrong-figure-numbers/ I really don't know the technical reason for doing this change, but since it worked and Latexila is my favorite tex editor, I decided to share this.
Thanks for the examples and the link to the blog post. The bug is fixed: http://git.gnome.org/browse/latexila/commit/?id=46f5eced6797f020aa14a425091a8cd05ec85fa6 This will be available in the next versions (2.4.1 and 2.5.1).