I'm using the subcaption package to make subfigures in my document like so:
\usepackage{caption}
\usepackage{subcaption}
\begin{document}
\begin{figure}[ht]
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{images/1.png}
\caption{Subcap1}
\label{fig:1}
\end{subfigure}
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{images/2.png}
\caption{Subcap2}
\label{fig:2}
\end{subfigure}
\caption{Cap}
\label{fig:3}
\end{figure}
\end{document}
This compiles fine, but in the texstudio editor, the \begin{subfigure}
and \end{subfigure}
are highlighted as "unrecognized command". I have tried activating the caption, subcaption, subfig and subfigure cwl files at Options > Completion but this doesn't remove the highlight.
While this doesn't affect the compiling, it is rather annoying. Am I missing something or incorrectly using the packages?
Best Answer
Save this as
subcaptionTemp.cwl
in~/.config/texstudio/
or%APPDATA%\texstudio\
!Then go to your preferences and load this file:
I would be happy for any feedback. If this works nicely for you, I will submit it to the maintainers of TXS.