[Tex/LaTex] Warning refers to unrecognized command, but file can still be compiled

compilingpackagestexstudio

Good afternoon everyone,

I am using a master document in TeXstudio which imports several separate .tex-files and contains the following code:

\documentclass[11pt]{article}
\usepackage{packBWR}
\begin{document}

\input{TeX-files/Sep_file1.tex}
\clearpage

\input{TeX-files/Sep_file2.tex}
\clearpage
\end{document}

In these subdocuments (that are called by the input command), the compiler indicates that it cannot recognise commands, such as align and bmatrix. When I compile the whole document through for instance Sep_file1.tex, the whole document is updated without any warnings and errors remaining.

I suspect that the packages cannot be detected in the subdocuments before the compilation process starts. How can I solve these warnings, so I can prevent that most of the code turns into a red block?

Extra information:
The file packBWR.sty is a custom package file, which includes the following packages and alterations:

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{pdflscape}
\usepackage[margin=2.0cm]{geometry} % side margins of 1cm
\numberwithin{equation}{section} % section numbering also in eqns.
\setlength{\parindent}{0cm} % no indentations

Best Answer

TeXstudio tries, to determine the valid commands in a document. For details see FAQ: How does TeXstudio know about valid commands?

However, this detection is not perfect. It may be inaccurate depending on the content of your style file. Note, also that local style files are currently not interperted by TXS (i.e. putting the sty file next to the tex document). The solution is to create a custom cwl file.