# Rename label and automatically update all references

Suppose, we have a section with a label \label{content}. This label is referenced at multiple occasions via \ref{content}.

During the writing process the content of the section changes and we would like a label name that properly reflects the content (so we do not get confused ourselves). Therefore, we replace \label{content} by \label{newContent}. The problem is that we have to manually update all references to that label.

Almost every programming IDE has a built-in function that lets you rename variables and updates all references to that variable automatically. A simple search and replace might be sufficient in some cases, but will fail every time the label name is part of some other content in the document. Of course, we could make label names sufficiently complex and thus unique, but this does not seem practical either.

Hence, I am looking for an editor function that can automatically update all references when a LaTeX label has changed. Preferably, this feature exists in kile or texstudio, but I am open to other editors as well.

• If you search \ref{content} explicitly then there shouldn't be overlap with the other content in your document? – Troy Oct 11 '17 at 14:49
• Good point, that will work! Still happy to hear if any editor has this feature. – jpmath Oct 11 '17 at 14:53
• The whole point of using \ref{label} is so that you can reference whatever label refers to even though the actual reference may change. If you rewrite the "content" so that the label should refer to some "new content" then update the label!? In my documents I sometimes change a lemma to a proposition, for example, so my label will change from L:something to P:something but this happens fairly infrequently and it is very easy to do with any decent editor using a global search and replace. I think you need to add specific details to explain why what you're asking makes sense. – Andrew Oct 11 '17 at 16:01
• With LyX if you rename a label, the cross-references are renamed as well automatically, and it does not allow you to make duplicate labels, but LyX is a document preparation system, not really a LaTeX editor. – Fran Oct 12 '17 at 4:59
• @Andrew: The idea is to have speaking variable / label names to avoid confusion. At least in programming, consistency between a variable name and its function / semantics is very important and I would like to apply the same principle to label names. – jpmath Oct 12 '17 at 7:51

On any label ore ref argument: Context Menu -> Find Usages
• This is exactly what I am looking for. Unfortunately, I have this context menu only on references, not on labels, and the labels do not get renamed using Replace All. May this is because I am using only TeXstudio version 2.10.8 (the version included in the latest Ubuntu LTS release)? Are there snap packages with up-to-date versions of TeXstudio? – jpmath Oct 13 '17 at 8:52