I'm using the caption
package in TexStudio, and it correctly highlights the various parts of the \caption
command, but it does no such thing for the \captionof
command. So I'm trying to write a custom .cwl
for \captionof
. This command takes three fields:
\captionof{floattype}[tocentry]{caption}
So a typical usage would be something like this:
\captionof{figure}[A Roman banquet]{A Roman banquet as depicted by John the Painter. Note the lack of spices and the limited selection of beverages.}
The floattype
field can be at least figure
or table
. I assume there are more possibilities, but I haven't had the need for them. The tocentry
field is a short caption for the TOC, and the caption
field is a full caption. Both are text fields, obviously.
With the \caption
command, Tex Studio highlights the caption
field according to its configuration, making it easy to find, and allowing it to be spell checked.
So I would like to do the same with the .cwl
entry for \captionof
. I've tried \captionof#S
, copying the autogenerated .cwl
entry for \caption
in caption3.cwl
, but it does nothing. I've tried \captionof{floattype}[short]{title}
following latex-document.cwl
's entry for \caption
, but this didn't work, either. I've also tried to define the different fields following the manual, and I came up with \captionof{floattype}[TOCentry%text]{caption%text}
and captionof{floattype}[TOCentry%text]{caption%title}
, but these also do nothing.
Could anyone give me a hand crafting a proper .cwl
entry for \captionof
?
I'm using TexStudio 4.2.3 with TexLive 2021. TexStudio detects my custom .cwl
file, and I've selected it to autoload in the configuration.
EDIT: In the screenshot is the result of implementing the suggestion to add \captionof{float type}[list entry%text]{heading%title}
to custom .cwl file. "This is a long caption" should be highlighted in purple, but is not.
\caption
and\captionof
highlighting is that the TOCentry argument is spellchecked in the former but not the latter (the second braced arg of\captionof
should still be spellchecked). If that's what you want then you can add\captionof{float type}[list entry%text]{heading%text}
to your custom cwl.heading%text
withheading%title
in order to get this field highlighted just like section names, and nothing happens. Any idea why?%text
has higher priority than%title
. If you want this then copy caption.cwl, change the \captionof lines to have%title
, and place it in the.../texstudio/completion/user
directory.