1

I defined a new command \FIGURE, which takes all arguments for the filepath, label, short/long caption and size and then builds a figure environment for this. I.e. I also define the label for this figure within the command using argument 2 with

\label{fig:#2}

The problem hereby is, that the auto-completion for references to this figure in TeXMaker is corrupted. Meaning, if I type \ref{... it only suggests \ref{fig:#2} as reference, at it is defined in the new command.

Is there any way to teach TeXMaker to interpret this new defined command, so that he also suggests \ref{fig:dummy} as an option.

MWE below (need to provide a dummy.jpg file to compile)

\documentclass[a4paper,11pt]{report}
\usepackage{graphicx} %Make \includegraphics command available
%------------------------------------------------------
% New command for easy figure environment
% #1 filepath
% #2 label
% #3 short caption
% #4 long caption
% #5 size
\newcommand{\FIGURE}[5]{
  \begin{figure}[hbt!]
    \centering
    \includegraphics[width=#5]{#1}
    \caption[#3]{#4}
    \label{fig:#2}
  \end{figure}
}
%------------------------------------------------------
\begin{document}
  \FIGURE{dummy.jpg}%
         {dummy}
         {Short dummy caption}%
         {Long dummy caption}%
         {0.8\textwidth}             
  This is text referencing \ref{fig:dummy}.             
\end{document}

closed as unclear what you're asking by user31729, Zarko, egreg, Mensch, barbara beeton Feb 20 '17 at 2:08

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    My guess it that the only thin TeXMaker is doing is looking for any \label{...} in the current dir. Makeing shortcuts like this is generally not a good idea as it makes the code a lot less readable. Consider a TM user command that will insert a figure template instead. – daleif Jan 21 '15 at 13:53
  • Since the setup is always the same for all figures, apart from the text provided for the captions, I thought it would make it MORE readable, since I see at this point there will be a figure with the known setup. Indeed TeXMaker is only looking for \label commands, but I was hoping to somehow use a way, so that TeXMaker kind of follows this command and correctly interprets the \label inside the new command – HeXor Jan 21 '15 at 13:58
  • 1
    I wouldn't say that that syntax is more readable. Also why should I want to write long and short caption every time. What if the figure needs to be rotated, what it at this particular point hbt! is not a good point (and why is p not on that list). And you will have to know that dummy is translated into fig:dummy. For ones own docs it might be fine, but if it ends up as something that goes to others, I'd much prefer the full version. – daleif Jan 21 '15 at 14:27
  • 1
    If you absolutely want to make a command interface, why not make it key=value based instead? Then you can test for the existence of a short caption, and only use it if needed. See eg xkeyval and etoolbox, the later has some good tools to test for empty ness. – daleif Jan 21 '15 at 14:29
  • Yes you're right, it might be nothing to hand on to someone else, but I am only using it for my own document. And yes I am a lazy person, this is why I am using this interface. But maybe your idea with the TeXMaker user command to insert a template for this environment is the best way to go – HeXor Jan 21 '15 at 15:15