TeXStudio does not recognize \colon
The macro \colon
is defined in plain.tex
as a punctuation mark (:
is a relation symbol in math mode)
\mathchardef\colon="603A
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:
\colon#m
Notes:
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”).
Code
\documentclass{article}
\begin{document}
$a:b$\par
$a{:}b$ \par
$a\mathrel{:}b$ \par
$a{:\,}b$ \par% \colon
$a\colon b$ \par
a \colon b
\end{document}
Screenshots