How to name arguments in \newcommand?

How to name the arguments in \newcommand so that when you call the macro they don't appear as {arg1}{arg2}... etc. but with the names each argument represent {caption}{label}... etc. without the use of a .cwl file.

I'm trying to implement the following \newcommand

\documentclass{article}

\usepackage{ctable}
\usepackage{mwe}

\newcommand{\qfigure}[5]{\ctable[
caption= {#1},label= fig:#2,figure, pos=H,botcap, mincapwidth= #3 mm]{c}
{}{\includegraphics[width=#4\textwidth]{#5}}}

\begin{document}

% \qfigure{arg1}{arg2}{arg3}{arg4}{arg5} % They would appear like this in Texstudio
\qfigure{An image example}{test}{70}{0.5}{example-image-a}

\end{document}


As you can see there are five arguments where each one represents the caption, label, min width of caption (ctable parameter), width and file name respectively.

Thanks in advance for any help.

• Welcome to TeX.SX! I don't think you can do this without a .cwl file, which is the only way for TeXStudio for being aware of macros. – egreg Jun 16 '15 at 22:17
• @egreg isn't there a package that allows me to name the arguments? If there's not I guess I'll learn how to create a .cwl (any resource to help with this?) Thank you – user80203 Jun 16 '15 at 22:23
• Packages work on the TeX side, which knows nothing about the editor you're using. – egreg Jun 16 '15 at 22:24

I don't think this is possible without a .cwl file. But it's really easy to do this using a .cwl. You can just create a text file with the following code and name it mystyle.cwl.

\qfigure{caption}{label}{mincapwidth}{width}{filename}#g


The #g just indicates to TeXstudio that this is a command that includes a graphics file (so that the image will pop up over your code if you hover over the command, like it does with \includegraphics).

Put mystyle.cwl with your other .cwl files (see Where does TeXstudio store the .cwl files for hyperref and xspace?) and check mystyle.cwl in Options | Configure TeXstudio... | Completion. Then your qfigure command will show up in the autocomplete box with the arguments named as you specified in the .cwl.

• I'll upvote your elaborate answer, since you've got no chance to get it accepted -- the user profile seems to be deleted etc. – user31729 Jun 16 '15 at 23:16

A "cross-editor" answer is that since you are defining the command and you have the right to name it, you can use (in some cases) some initials of the arguments as reminders for you to use:

For example:

\qfigureCapLabMcWdFn{caption}{label}{mincapwidth}{width}{filename}


I know that in this example is not really good idea but have used similar approach in the past in other cases and was a reasonable helped for me: