27

I'm starting to use TeXStudio. I'm having some issues, for example with

\begin{align*}
\sqrt[n]{a}^2-\sqrt[n]{ab}&=m\sqrt[n]{a}\\
\end{align*}

When i put the point on align* i get a small message unrecognized command, when it is in \sqrt or ^ i get the message math command outside math env, and something similar happens with & when it gives me the message tabular command outside tabular env. These commands are highlighted with an orange background.
I have similar mistakes with \eqref,\implies. Some commands as \title,\author or \sqrt(when it is between dollar signs) don't present any problem.

When i build the PDF, i have no problems at all and it gives me the desired result.
I'd like that TeXStudio recognize these commands

David Carlisle
  • 757,742
Zero
  • 627
  • 1
  • 6
  • 11

4 Answers4

23

TeXStudio recognises commands that it finds in files ending with .cwl. The \eqref command and the align* environment come from the amsmath package, so you need to make sure that amsmath.cwl is loaded. Under some circumstances, this will happen automatically, but the mechanism isn't foolproof (e.g. it doesn't know that amsmath can be loaded indirectly via \usepackage{mathtools}).

On a Mac, you can ensure that amsmath.cwl is loaded by going to

TeXStudio --> Preferences

selecting Completion on the left and checking the box next to amsmath.cwl. Presumably the procedure is similar on other operating systems. If the other unrecognised commands also come from packages for which TeXStudio has cwl files, activate these as well. Section 1.4 of the TeXStudio manual explains how to add your own cwl file for commands that do not come from standard packages.

Ian Thompson
  • 43,767
  • 1
    Same can be done on Win7(x64) – Stat-R May 07 '13 at 14:41
  • 1
    I have activated the same, but it does not seemed to work. Most of the math symbols like \alpha,^,_ are highlighted. When I build the pdf I don't have a problem – soori Jul 10 '13 at 03:27
  • This fix worked for me yesterday in TeXstudio 2.6.6 but isn't working today. The computer was shut down overnight. For example, \euro{} produces the proper output () but is considered an "unrecognized command", even though I have the eurosym.cwl selected as a completion file. – Cerran Feb 19 '14 at 10:14
  • @Cerran do gedit ~/.config/texstudio/eurosym.cwl and add \EUR{amount} \euro \geneuro#* \geneuronarrow#* \geneurowide#* \officialeuro#* \eurobars#* \eurobarsnarrow#* \eurobarswide#* (one command per line) – LaRiFaRi Aug 28 '15 at 08:29
1

See also FAQ: How does TeXstudio know about valid commands

Tim Hoffmann
  • 11,159
0

When I was adding superscripts to one of my research articles, I ran into a similar problem. The easiest way I found was to wrap the text with $, which activates inline math mode.

Example:

 $ 1^{2} $

Result:

12

I hope this information can help.

0

Instalei o TeXstudio e dei a opção de novo. Ao tentear digitar o primeira linha de codigo recebo o erro...

unknown at 893035 (TXS-Version 4.3.1 R ) [bt] 000000000064dd70 ??? error: 487

bila
  • 1