0

I am using the code \label{eq:1} with \eqref{eq:1} to reference equations in LaTeX. The actual reference is dynamic, but the label name is not. So if I insert a new equation halfway through my document and want to reference it I need to use a label name that is not in sequence. This can get confusing and I might forget which label name I am up to if I am using numbers.

I was wondering, is there a way I can have sort of dynamic equation label names? I am using the TeXstudio GUI. Is there is some kind of macro I can build that updates the equation labels names to show the equation number? This would involve some sort of text editing referencing equation numbers in a compiled document, which seems difficult.

When using MS Word for math documents I have written VBA code that has done this for its reference method. It seems to me, if this type of updating is not possible in LaTeX then this is one thing MS Word has over it.

Ideally, using TeXstudio, when you insert new equation label it would auto fill the label name with the next numbered label. Then there would be a way to update the label names to be the same as the equation number. This way when you want to reference an equation from your output you would just type this in as the label name, like \eqref{eq:1.11} where this would be a reference to equation 1.11 .

Thanks in advance, Ed.

PS: Some of the 'Questions that may already have your answer' mentioned that \label{eq:HeatEquation} is best used to reference specific important equations, but this is not what I want.

  • 1
    Welcome to TeX.SE! Don't doing this. This lead to confusion in cross referencing. – Zarko Jun 27 at 23:24
  • You wrote, "I might forget which label name I am up to if I am using numbers." This is precisely why it's not a good idea to use (an increasing sequence of) numbers in the labels, e.g., eq:1, eq:2, etc. – Mico Jun 27 at 23:55
  • @Zarko and Mico. To me, what I propose is a perfectly good idea. Any confusion with what I propose would only ensue because the subject matter (or the way it has been thought out), and not to do with type setting really. I guess this is more than just a LaTeX question and to do with text editor as well. As far as I am concerned, in this matter MS Word is really a more complete solution (with the use of VBA) than LaTeX. – Eggs Jun 28 at 0:03
1

The name of a cross-referencing-label is something that in LaTeX comes into being during the process of writing/creating/preparing the .tex-input-file.

Unlike the program MS-Word, which also intervenes during the stage of writing/creating/preparing the input-file/the .doc(x)-file, the program (La)TeX comes into action when the .tex-input-file is already written/created/prepared / when the stage of writing/creating/preparing the .tex-input-file is interrupted or over.

Thus what you ask for needs to be accomplished by means of the tools which you use for writing/creating/preparing the .tex-input-file in question.

Thus a solution cannot be based entirely on TeX-macros.

Probably someone is able and willing to make up a solution which is based on editor-macros of the GUI-editor TeXstudio.

Another approach could be patching the \newlabel-command so that you get an external file with a table where you can for the name of each cross-referencing-label look up the associated numeral value. That table in turn might be useful when implementing your own mechanism for in the .tex-input-file replacing names of referencing-labels with other names during stages of writing/creating/preparing the .tex-input-file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.