I've read quite a few questions and answers on this web site but none helps me to resolve my problem. I am using \ref and \eqref commands most often. After installing and re-installing the latest version of TeXstudio (2.10.0, 5.5.0), in some files the command \ref offers a list of available labels, but in some it gives an empty list although the file itself contains plenty of labels. At the same time, \eqref does not work at all. I would be grateful if somebody could help! Thanks!

  • 1
    Welcome to TeX.SX! I don't use such editors, but I could imagine that TeXStudio needs an .aux file to get the labels from? – user31729 Sep 17 '15 at 8:55
  • TeXstudio rolled out an update (2.10.2) yesterday, in the changelog it says - fix detection of \ref commands – Francis Sep 17 '15 at 9:26
  • @Christian -- you are right, TeXstudio does need .aux files. – Alex Sobolev Sep 17 '15 at 12:26
  • @Francis, thanks. Downloaded and tried. \ref or \eqref did not work until TeXstudio completely re-installed. Now \ref works, but \eqref does not. – Alex Sobolev Sep 17 '15 at 12:32
  • @AlexSobolev: I am using TeXstudio 2.10.2 and have no problem with either \ref or \eqref. Have you tried completely uninstalling TeXstudio and removing all user profile (e.g. in AppData for Windows)? – Francis Sep 18 '15 at 17:13

This seems to be a known bug in TeXstudio 2.10.X that is still not fixed in the current release 2.10.8; but there is a workaround, which worked for me and does not cause problems as far as I can tell:

For now, txs generates cwl files for syntax checking.
Please make sure that those files don't contain "\ref#S" or  "\label#S".
Just delete those lines and it should work again.

See also here on where to find the cwl files.

| improve this answer | |
  • It works here. That ( sourceforge.net/p/texstudio/bugs/1480 ) minimal example with bug works fine here. I'm using TXS 2.10.8 – Sigur Jan 26 '16 at 16:38
  • 1
    I guess it depends on which cwl files you activate by default (under setting - completion) – Sebastian Jan 26 '16 at 20:44
  • I had activated a lot of cwl files by default (by checking them in the config dialog), so also the minimal example did not work for me. I did not erase my configuration before updating, which might solve the issue, as well. In case the OP has similar configuration than I have/had, he might profit from the workaround. – Sebastian Jan 27 '16 at 10:59

When \ref offers the list of labels but \eqref does not, add \eqref{key}#r to your .cwl file. Then save it, close TeXstudio and again open TeXstudio.

I found it here and it solved the problem for me. Unfortunately, I don't have a link to an explanation of key and #r or of .cwl's in general.

| improve this answer | |

As of version version 2.10.8 the default cwl files are built in and cannot by modified directly

For newer versions TXS searches for cwl files in three different locations:

  1. settings directory/completion/user
  2. builtin cwls
  3. settings directory/completion/autogenerated

you may have a look at the source code of the buitlin cwls. In OSX, create a custom.cwl under /Users/username/.config/texstudio/completion/user/ with the following:

# \FG{label}#r

If like me you have defined custom commands to consistently label figures, tables, sections (e.g. \newcommand{\FG}[1]{Fig.~\ref{#1}}), adding them to the custom.cwl makes the completion work for them too.

Last, you need to restart your TexStudio and enabled custom.cwl in the TexStudio settings: Preferences -> Completion

| improve this answer | |

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.