Texstudio \begin{subfigure} 无法识别的命令

Texstudio \begin{subfigure} 无法识别的命令

我正在使用 subcaption 包在我的文档中制作子图,如下所示:

\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}

编译正常,但在 texstudio 编辑器中,和\begin{subfigure}\end{subfigure}突出显示为“无法识别的命令”。我尝试在选项 > 完成中激活标题、子标题、子图和子图 cwl 文件,但这并没有消除突出显示。

虽然这不会影响编译,但确实很烦人。我是否遗漏了某些内容或错误使用了软件包?

答案1

将其另存subcaptionTemp.cwl~/.config/texstudio/%APPDATA%\texstudio\

# manipulated the auto-generated subcaption.cwl for Holt
# subcaption package
# Axel Sommerfeldt 04/16/2013
# URL: http://mirror.switch.ch/ftp/mirror/tex/help/Catalogue/entries/subcaption.html

#include:caption
#
#
# Chapter 1 Loading the package
#
#
\captionsetup[sub]{%<options%>}
#keyvals:\captionsetup
margin=%<num%>pt
margin={%<left amount%>,%<right amount%>}
margin*=%<num%>pt
margin*={%<left amount%>,%<right amount%>}
font=#scriptsize,footnotesize,small,normalsize,large,Large,normalfont,up,it,sl,sc,md,bf,rm,sf,tt,singlespacing,onehalfspacing,doublespacing,{strech=%<amount%>},normalcolor,{color=%<colour%>},normal
font+=#scriptsize,footnotesize,small,normalsize,large,Large,normalfont,up,it,sl,sc,md,bf,rm,sf,tt,singlespacing,onehalfspacing,doublespacing,{strech=%<amount%>},normalcolor,{color=%<colour%>},normal
font={%<option 1%>,%<option 2%>}
labelfont=#scriptsize,footnotesize,small,normalsize,large,Large,normalfont,up,it,sl,sc,md,bf,rm,sf,tt,singlespacing,onehalfspacing,doublespacing,{strech=%<amount%>},normalcolor,{color=%<colour%>},normal
labelfont+=#scriptsize,footnotesize,small,normalsize,large,Large,normalfont,up,it,sl,sc,md,bf,rm,sf,tt,singlespacing,onehalfspacing,doublespacing,{strech=%<amount%>},normalcolor,{color=%<colour%>},normal
labelfont={%<option 1%>,%<option 2%>}
textfont=#scriptsize,footnotesize,small,normalsize,large,Large,normalfont,up,it,sl,sc,md,bf,rm,sf,tt,singlespacing,onehalfspacing,doublespacing,{strech=%<amount%>},normalcolor,{color=%<colour%>},normal
textfont+=#scriptsize,footnotesize,small,normalsize,large,Large,normalfont,up,it,sl,sc,md,bf,rm,sf,tt,singlespacing,onehalfspacing,doublespacing,{strech=%<amount%>},normalcolor,{color=%<colour%>},normal
textfont={%<option 1%>,%<option 2%>}
labelformat=#default,empty,parens,simple,brace
labelsep=#none,period,space,quad,colon,newline,endash
skip=%<num%>pt
list=#false,true,no
hypcap=#false,true
indention=%<amount%>pt
position=#auto,top,above,bottom,below
#endkeyvals
#
#
# Chapter 2 The \subcaption command
#
#
\subcaption{heading}#/minipage
\subcaption[list entry]{heading}#/minipage
\subcaption*{heading}#/minipage
\setcaptionsubtype#S
\setcaptionsubtype*#S
#
#
# Chapter 3 The subfigure & subtable environments    
#
#
\begin{subfigure}{width}
# pos can be b (default: )
\begin{subfigure}[pos]{width}
\begin{subtable}{width}
\begin{subtable}[pos]{width}
\end{subfigure}
\end{subtable}
\captin@For{subtyelist}#S
#
#
# Chapter 4 The \subcaptionbox command
#
#
# inner-pos can be c, l, r, s (default: c)
\subcaptionbox[list entry]{heading}[width][inner-pos]{contents}
\subcaptionbox[list entry]{heading}[width]{contents}
\subcaptionbox[list entry]{heading}{contents}
\subcaptionbox{heading}[width][inner-pos]{contents}
\subcaptionbox{heading}[width]{contents}
\subcaptionbox{heading}{contents}
\subcaptionbox*{heading}[width][inner-pos]{contents}
\subcaptionbox*{heading}[width]{contents}
\subcaptionbox*{heading}{contents}
#
#
# Chapter 5 The \DeclareCaptionSubType command
#
#
# numbering-pos can be arabic, roman, Roman, alph, Alph, fnsymbol... (defaul: alph)
\DeclareCaptionSubType[numbering scheme]{float type}#*d
\DeclareCaptionSubType{float type}#*d
\DeclareCaptionSubType*[numbering scheme]{float type}#*d
\DeclareCaptionSubType{float type}#*d
#
#
# Chapter 6 References
#
#
\thesubfigure#S
\thesubtable#S
\p@subfigure#S
\p@subtable#S
\subref{key}#*r
\subref*{key}#*r
#keyvals:\captionsetup
subrefformat=#parens
#endkeyvals
\phantomsubcaption
# other commands
\subfigureautorefname#S
\subfigurename#S
\subtableautorefname#S
\subtablename#S
\theHsubfigure#S
\theHsubtable#S

然后转到您的偏好并加载此文件:

在此处输入图片描述


我很高兴收到任何反馈。如果这对您有用,我会将其提交给 TXS 的维护者。

相关内容