1

I'm currently writing a thesis using LaTeX. I have a couple of figures (diagrams) in my document and wanted to reference them in a more convenient way than always writing "bla in figure \ref{labelname}".
So I wrote an own command:
\newcommand{\reffig}{figure \ref}

This is working. However, if I use it, TexStudio does not recognize the usage of that label. If I hover the cursor over the label of the figure, it will show 0 references.

Same for labels in chapters with my new command:
\newcommand{\refsec}[1]{section \ref{#1} - \nameref{#1}}

Did I do something wrong declaring my commands? Is there a way to get TexStudio to recognize the references?

Thanks a lot!

Auri
  • 11
  • 4
    Welcome to TeX.SE. Either there is a method to teach TeXStudio such macros and handle them accordingly or rather switch to the more appropiate cleveref package, that automatically detects the type of the reference, i.e. \cref{foofigure} will show you Figure 2.1 etc, i.e. you dont need to remember then, whether you need \reffig or \refsec etc. –  Dec 28 '18 at 11:13
  • That's a very handy package! It doesn't do what my second command does, but I'll use it anyway. Thanks for the hint! – Auri Dec 28 '18 at 12:19
  • 2
    I agree with @ChristianHupfer: better use cleveref. If you want to configure texstudio instead, you have to create a custom .cwl file, see https://tex.stackexchange.com/questions/414281/configuring-auto-completion-with-texstudio for more information – samcarter_is_at_topanswers.xyz Dec 28 '18 at 15:24
  • @Auri: You can easily do \refsec with cleverref as well, by saying \newcommand{\ncref}[1]{\cref{#1} - \nameref{#1}}... –  Dec 28 '18 at 15:44

0 Answers0