0

Is there a way to have completion for cref references for labels defined in a command macro?

\newcommand{\midpict}[4]{    
    \begin{center}
        \begin{figure}[H]
            \begin{center}
                \includegraphics[width=#2\textwidth]{#1}
                \caption{\label{fig:#4}#3} 
            \end{center} 
        \end{figure}
    \end{center}
}

I use it like

\midpict{./template/placeholder.png}{0.5}{This is a placeholder}{placeholder-img-1}

And I'd like to use Cref{fig:placeholder-img-1} but have the completion feature for this label.

  • 2
    What are you doing with that macro? Why are there two center envs? and why is that not floating? IMO you are better of making a template in your editor and have it fill in this code instead of attempting to get the editor to parse an extra macro in order to find the label. – daleif Jul 3 '18 at 9:53
  • You're right, the outer center environment isn't necessary. Can you specify what you mean by "making a template in my editor"? – Humpawumpa Jul 3 '18 at 10:08
  • Texstudio has an interface for making small templates that can be attached to a shortcut. That template will then insert the code and perhaps ask you for data to fill in the template, since I don't use texstudio I cannot provide more details, see the texstudio manual for information. What you're doing here is not generally recommended as it becomes hard to keep track up after a while. – daleif Jul 3 '18 at 10:18
  • Off-topic: The center environment will add additional spacing to your figure, better use \centering inside your figure. – user36296 Jul 3 '18 at 10:28
  • And of course avoid H (tex.stackexchange.com/questions/370627/…). – TeXnician Jul 3 '18 at 11:40

Your Answer

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

Browse other questions tagged or ask your own question.