# autocomplete with labels defined by user commands

I use a command that automatically generates labels to include pictures:

\newcommand{\plot}[3]{

\begin{figure}[htp]
\centering
\includegraphics[#2]{Fig/#1}
\caption{#3}
\label{fig:#1}
\end{figure}
}


How could I make texstudio autocomplete suggest the labels generated by the command?

I created a simple myDefs.cwl:

\plot{label}#l
\figref{label}#r


Which works with:

\plot{abc}{width=\columnwidth}{caption}
\figref{abc}


but how could I make label "fig:abc" to appear among suggestions to keep figures separate?

• You can create a custom .cwl file and specify what the auto completion should suggest. See texstudio.sourceforge.net/manual/current/… for details. – user36296 Nov 6 '17 at 11:58
• note that you should not use \center (that is the internal form of \begin{center} it should be \centering also [h!] is usually wrong and latex will generate a warning and change it to [ht] but in most cases [htp] is better (not including p makes it far more likely that the figure goes to the end of the document) – David Carlisle Nov 6 '17 at 12:29
• Thanks for reference and suggestions! How could one issue a label different from arg1 for auto-completion though? – Vladimir Kazei Nov 6 '17 at 15:03

\plot{fig:abc}{width=\columnwidth}{caption}