0

because of some ugly corporate design I needed to create the following figure environment/design with the caption on the right side.

Problem is, that I don't get suggestions from the label inside the

\figthree{sample.jpg}{caption}{fig:label}

command.

\newcommand{\figthree}[3]{\begin{figure}
[!h]%\makebox[131.8mm+4.32cm][l]{
                \raggedright
\begin{minipage}[t]{131.8mm}%               \input{#1}  
            \vspace*{0pt}
            \includegraphics[width=\linewidth]{#1}
        \end{minipage}
%   \hspace*{2mm}
    \begin{minipage}[t]{42mm}
            \vspace{-\ht\strutbox}%
            \captionof{figure}{#2}\label{#3}%
        \end{minipage}%}
\end{figure}}
  • 2
    TeXStudio's parser is unlikely to see the label there really, because it would need to parse the (really weird) \figthree command and understand that its third argument is a label. A hack that could work is to add \iffalse\label{fig:label}\fi. It wouldn't be seen by TeX but TeXStudio might see it... – Phelype Oleinik Aug 10 '18 at 14:33
  • 1
    You can write a cwl file for your command \figthree. Maybe something like \figthree{imagefile}{caption%text}{label}#l should work. – Troy Aug 10 '18 at 14:38
  • 1
    @Troy doesn't that just make an interface for \figthree? The OP is looking for a solution that adds the label to the list of known label keys you get when you write \ref – daleif Aug 10 '18 at 14:48
  • 1
    @daleif Yes, true, but it also adds the third argument passed to \figthree to the list of labels recognized by TXS. That's the point of the #l classifier. Hence, the label will be presented as an option for autocompletion when using \ref. – Troy Aug 10 '18 at 14:50
  • 1
    @Troy ahh, nice – daleif Aug 10 '18 at 14:51
0

Write a .cwl file for your command \figthree and use the special argument name label with the classifier #l so that TXS recognize the third argument as a label. See this answer if you are unsure how to write a .cwl file.

\figthree{imagefile}{caption%text}{label}#l

Proof that it works:

pic

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.