What is the file to load the command \colon to be recognized (as a known command) by TeXStudio? If I add it to the personal command it works but I guess that this command comes from some package.

ps: I'm talking about highlighting unknown commands.

ps2: I tried grep colon *.cwl on my .config/texstudio folder and I found


that is, no \colon command.

  • I don't think you need any packages. Are you using this in math mode? Commented Oct 29, 2012 at 23:53
  • 1
    @PeterGrill, sorry. Probably I'm confusing you guys. My question is about unknown commands by the editor not by LaTeX. Everything is fine with the compilation.
    – Sigur
    Commented Oct 29, 2012 at 23:57
  • Ok, then perhaps this is a duplicate of TeXStudio doesn't recognize some commands. Commented Oct 30, 2012 at 0:20
  • I found that topic, but it does not consider the command \colon. I am not able to find this command.
    – Sigur
    Commented Oct 30, 2012 at 0:23
  • 1
    You could just add \colon#S to a custom .cwl file. (It is defined in plain.tex: \mathchardef\colon="603A % colon as a punctuation mark and is redefined by amsmath.) Commented Oct 30, 2012 at 3:56

2 Answers 2


The macro \colon is defined in plain.tex as a punctuation mark (: is a relation symbol in math mode)


and redefined by amsmath.

Unfortunately, TeXstudio doesn’t recognize the command even if the amsmath.cwl completion file is selected.

But we can create our own .cwl file. On Windows, custom .cwl files are stored and recognized by TeXstudio in %appdata%\texstudio\completion\user. In Linux in ~/.config/texstudio/completion/user. (more information in 4.13.4 cwl file placement)

Create your own .cwl file, I named it custom.cwl. One line suffices:



  • m declares it as a math mode command, the use of \colon in text mode will still give you the unrecognized highlighting.
  • S, as I understand it, gives you recognizing (i.e. correct highlighting) but not completion.

After saving the file custom.cwl start TeXstudio go to the “Options” menu and open the “Configure TeXstudio” dialog. In the “Completion” tab select custom.cwl and apply your changes (“OK”).


$a{:}b$ \par
$a\mathrel{:}b$ \par
$a{:\,}b$ \par% \colon
$a\colon b$ \par
a \colon b


auto-completion \colon is highlightet correct

  • Reference: TeXstudio user manual, 4.13 “Description of the cwl format” Commented Dec 15, 2012 at 3:05
  • How do you create a .cwl file though? I tried creating in in TXS and one in with a text editor and neither worked when I dragged it into ~/.config/texstudio (for Mac). Commented May 8, 2013 at 18:32
  • Have you activated the .cwl file in the Options menu/Completion tab (see last paragraph of Notes section of this answer)? Commented May 8, 2013 at 18:37
  • All I see under Options is "Load Profile", "Save Profile", "Save Current Settings", "Define Current Document as Master Document", and "Automatically Restore Session at Next Start". When you create the .cwl file, are you typing \colon#m in TXS or some other application? (I should note that I'm on a Mac.) Commented May 8, 2013 at 18:48
  • It doesn’t matter where you type it, just be sure it is a normal text file (and it is probably better to not use UTF8). Sorry, the correct route is Options, Configure TeXstudio, Completion tab (as in my answer above). Commented May 8, 2013 at 18:58

\colon is made known to TeXStudio in latex-mathsymbols.cwl, which, as a pre-customized .cwl file, is not directly accessible to the end user, since it is in the compiled program files. (Found through googling colon site:http://svn.code.sf.net/p/texstudio/code/trunk/completion/; also see Where does TeXstudio store the .cwl files for hyperref and xspace?)

For some reason, all commands from that file are recognized, i.e. suggested as autocompletion and not marked as unknown commands, except for \colon and \lnot. This seems to be a bug to me. I reported it as bug #728 \colon and \lnot from latex-mathsymbols.cwl aren’t recognized.

  • So should I try it with other commands or is there a bug the ability to create any sort of custom command? Commented May 8, 2013 at 19:59
  • 1
    @AlanH In the long run, I expect this bug to be fixed in one of the next releases of TXS, so you won’t have to worry about \colon anymore. If I understand your question correctly as asking if personal/customized .cwl files are broken in general, the answer is no. I just added \colon#m to my personal .cwl file, restarted TXS, and it is recognized just fine.
    – doncherry
    Commented May 8, 2013 at 20:05
  • so you were able to get \colon to show in the autocompletion? If so, then I must have done something wrong... Btw, I don't care so much about \colon, I was just trying to follow the example posted by Qrrbrbirlbel. Commented May 8, 2013 at 20:06
  • In my case, I created my personal cwl file with the same name as my package sty where I defined my personal command. So, only when I load my package TeXstudio suggest the command. The cwl file contains only the command (in my case, \alert{arg}). Nothing more at the end of line.
    – Sigur
    Commented May 8, 2013 at 20:19
  • 1
    @Sigur Depending on how complex the macro definitions in your personal .sty file are, TXS will automatically recognize the macros. (Not sure if it has to be in the texmf tree as well, this was the case when it worked for me.) However, custom .cwl definitons might be more precise and complete, e.g. in providing an autocomplete entry for a command with and without an optional macro.
    – doncherry
    Commented May 8, 2013 at 20:22

You must log in to answer this question.

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