1

So I have a modified document class where I use \RequiredPackage to load the packages into TeXstudio I need. The issue I have is that command does not trigger TeXstudio to load the associated *.cwl files as well. Basically, every command is not recognized but is correctly used when the document is compiled. I have read through the different answers and manuals but that has left me more confused then when I started.

How do I get TeXstudio to load the *cwl for the different packages I call in the document class? Conversely, if this is the absolutely worse way to do it, how should I set this up?

EDIT:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{myDoc}[2019/07/01, v0.2]
\RequirePackage{ifthen}
\RequirePackage{calc}
\AtEndOfClass{\RequirePackage{microtype}} 
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions* \LoadClass{article} \RequirePackage{siunitx}

I think the siunitx, ifthen, and calc cwl's should be loaded. When I compile, the siunitx commands are correctly interpreted but are unrecognized

EDIT 2: The commands appear highlighted in red, and when moused over with the cursor, the popup window says "unrecognized command"

7
  • I do not understand, what you want. Why should TeXstudio load all classes, you use for a document? Maybe you could post a small example of your code? I also don't understand, what you mean with " I use \RequiredPackage to load the package into TeXstudio". ´\RequiredPackage´ is a command, it doesn't effect TeXstudio in any way.
    – NelDav
    Commented Jul 30, 2019 at 21:57
  • ``` \NeedsTeXFormat{LaTeX2e} \ProvidesClass{myDoc}[2019/07/01, v0.2] \RequirePackage{ifthen} \RequirePackage{calc} \AtEndOfClass{\RequirePackage{microtype}} \DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}} \ProcessOptions* \LoadClass{article} \RequirePackage{siunitx} ``` I think the siunitx, ifthen, and calc cwl's should be loaded. When I compile, the siunitx commands are correctly interpreted but are unrecognized
    – Nebabon
    Commented Jul 31, 2019 at 6:56
  • Ah ok I think I understand, what you want to know. But I am sorry, I don't know, if there is a way to trigger TeXstudio to use that file automaticly.
    – NelDav
    Commented Aug 1, 2019 at 13:25
  • What exactly do you mean by "TeXstudio does not recognize the commands"?
    – schtandard
    Commented Aug 1, 2019 at 14:28
  • @schtandard The commands appear red highlighted, and when moused over with the cursor, are "unrecognized command"
    – Nebabon
    Commented Aug 1, 2019 at 16:01

2 Answers 2

2

When you load a package or document class, TeXstudio does not look into the source of that package/class to figure out which .cwl files to load – it just load the .cwl file of that package/class.

This also holds for your class myDoc. When you load it, TeXstudio looks for myDoc.cwl in some places, doesn't find it and gives up. If you want TeXstudio to know which packages are loaded, you have to tell it by creating myDoc.cwl

#include:article
#include:ifthen
#include:calc
#include:siunitx

and saving it in the appropriate folder. On Windows, this is c:\Users\<user name>\appdata\Roaming\TeXstudio\completion\user\. You can find examples of how to write it in the adjacent autogenerated\ folder.


The fact that you can compile just fine has nothing to do with all this. LaTeX will load the packages and execute the macro definitions therein regardless of if TeXstudio knows about it.

2
  • I assuming I will have to keep both the myDoc.cwl & myDoc.cls in sync?
    – Nebabon
    Commented Aug 6, 2019 at 18:44
  • Of course. TeXstudio does not monitor myDoc.cls.
    – schtandard
    Commented Aug 6, 2019 at 18:46
0

I just solved this problem!! Here is the solution:

Add the command \ProcessOptions\relax at the end of your .sty or .cls file. Then reopen the cwl created by txs and you will find txs has already added all the #include ...commands automatically!!!

You must log in to answer this question.

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