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!
- 11
3 Answers
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.
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.
- 263
-
It works here. That ( http://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
-
1I 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
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:
- settings directory/completion/user
- builtin cwls
- 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:
\eqref{label}#r
# \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
.auxfile to get the labels from? – Sep 17 '15 at 08:55- fix detection of \ref commands– Francis Sep 17 '15 at 09:26\refor\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