4

TeXstudio's autocomplete suggested \microfarad as a command so I attempted to use it but received an "undefined control sequence" error. There are easy workarounds (\micro\farad and \micro\F), but why does autocomplete think \microfarad exists if it apparently doesn't? I had never used \microfarad before because I didn't know it "existed" until I started typing in \micro\F and noticed the suggestion.

This appears to be the case for other commands like \microampere, \microgram, etc. I noticed the problem with \microfarad because there are shorter commands for the other units (\uA, \ug, etc.) but \uF doesn't exist either.

Why does TeXstudio's autocomplete suggest these non-existent commands?

I've found this problem on two separate Windows 7 machines, and strangely I cannot find an siunitx.cwl file on either machine.

MWE:

\documentclass{article}
\usepackage{siunitx}

\begin{document}
    \SI{1}{\microfarad}\\ % undefined control sequence
    \SI{1}{\micro\farad}\\ % works
    \SI{1}{\micro\F} % works
\end{document}
  • 2
    Autocomplete has not the slightest idea which commands are defined and which not. Don't let the editor trick you ;-) – Johannes_B May 7 '15 at 18:13
  • By the way, good example. – Johannes_B May 7 '15 at 18:13
  • @Johannes_B You're right; I re-worded the question a bit to ask why autocomplete is wrong. – Null May 7 '15 at 18:17
  • @Johannes_B some editors (and TeXStudio should be among them) have basic parsing capabilities (of course don't work with very complicated definitions), so your statement is not completely true. – giordano May 7 '15 at 19:05
  • @giordano I know, somebody told me that TeXstudio is even capable of learning new commands. I am not sure where the list is saved and editable and i also don't know after how many instances an item is added to the list. – Johannes_B May 7 '15 at 19:07
3

I think that this is a bug of TeXstudio. The problem is that TeXstudio has auto-completion support for certain commands hard-coded in, most likely for performance reasons. This can be easily checked by looking at the texstudio.exe in a text editor and searching for \microampere (line 68436 in version 2.9.4).

So I would say this is TeXstudio's bug and you should submit it in their bugzilla. I think this is a case for many other commands, so you could also suggest general cleanup of the hard-coded lists of commands.

Edit: I checked the source of TeXstudio 2.9.4 and really, the file completion/siunitx.cwl contains \microfarad, etc. These files must then be compiled into the binary which is distributed.

  • 1
    You have the source, one doesn't need to open a binary file to find it out. \microampere is in completion/siunitx.cwl. What's strange is that that file is different from the one present in the repository. It seems they have a repository but use something else as base to build the executable. – giordano May 11 '15 at 14:10
  • @giordano: I just checked the source code and edited my post as you added the comment. This is strange indeed. – Augustin May 11 '15 at 14:15
  • I'm using TeXstudio 2.9.4 on Linux and I don't have any siunitx.cwl even I can check it in the Options/Configure menu. – Sigur May 11 '15 at 14:17
  • @sigur: We are talking about the source code, though. See giordano's comment above containing the link. – Augustin May 11 '15 at 14:20
  • @Augustin, yes, I know. I just said that I can not find any cwl file on my system containing \microfarad on it. So how TXS could suggest it to me? – Sigur May 11 '15 at 14:24

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.