I added this command to reference sections (figures, chapters, etc.):


Now TeXstudio autocomplete shows me

enter image description here

but I am missing the autocompletion for the actual sections. Like in the autocomplete for \ref{.... Is this possible?

A not so nice solution would bt to skip the \ref command


and then go for example \secref{\ref{sec:setup}}.


2 Answers 2


Instead of reinventing the wheel, I would rather use cleveref. This will automatically insert the appropriate names of the referenced labels as well as supported by texstudios auto-complete.

For example in the following document


\usepackage[capitalise, noabbrev]{cleveref}




\cref{fig:bla} \cref{sec:test}


Texstudio will prompt

enter image description here

and the output will be

enter image description here


EDIT: This does not answer the question, as stated in the comments. In this answer, I explain how to add macros in texstudio, so that the cursor jumps to a specific location in that macro. A wholly different matter, indeed.

Original answer

Although I agree with samcarter, for the sake of completeness, there is a way to do the thing you originally wanted in texstudio.

Go to [Macros > Edit macros ...] Then create a new macro, give it a name, an abbreviation (not required and quite useless imho) and a trigger (good design is important for the triggers). In the code section, you would add


Save and close. In your editor window, type the trigger and the trigger text will automatically be replaced by the macro code \secref{section} with the focus of the curser select the word section in the braces, ready to be edited.

enter image description here

As you can see, I abuse of this function. (There's a lot of crap in the picture, as I was testing what was useful to me and I haven't cleaned up the mess, yet.)

btw, I use a space at the beginning and at the end of most of my triggers to prevent texstudio to convert "normal text" to some macro. E. g. the macro ml without the spaces would be really annoying, as any word containing the sequence 'ml' would get a macro right in the middle of it! If I was typing Umlaut without looking, I would get U\SI{aut and the rest of the text in the braces,}{\ml} which doesn't make sense at all. You can do much more with the triggers and the macros, just click on the ? next to the word "Trigger" and try for yourself.

  • 1
    Are you sure this would make the labels for the sections appear in the autocomplete box? If not, this does not answer the question.
    – Troy
    Feb 27, 2018 at 21:45
  • This does not answer the question. I misunderstood the question, as I now realize! It zeemz zomewon wass standing on ze leadership readwithastrongGermanaccent
    – thymaro
    Feb 27, 2018 at 22:05
  • Ok, no worries. I would suggest you delete the 'answer', however, lest someone else gets confused by this.
    – Troy
    Feb 27, 2018 at 22:08
  • Interresting anyway, did not knew that!
    – Finn
    Feb 28, 2018 at 12:56

You must log in to answer this question.

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