1

When using the command \ref{ it automatically suggests several arguments, such as eqn:equation1, fig:figure1, and so on.

I have defined the command \newcommand{\fref}[1]{Fig. \ref{#1}}, which rather simply puts Fig. in front of the reference number.

Is there any way to make \fref{ automatically suggest arguments, as \ref{ does? Ideally, it would only suggest arguments that begin with fig:.

This is for TexStudio, which controls this (as far as I know).

Jan
  • 829
Mauvai
  • 125
  • 3
    What you are describing sounds like a function of your editor and not of LaTeX. – Steven B. Segletes Apr 14 '15 at 18:10
  • @StevenB.Segletes Yeah, now what you mention it. Edited the question. – Mauvai Apr 14 '15 at 18:15
  • Unrelated: the definition should be \newcommand{\fref}[1]{Fig.~\ref{#1}} in order to avoid page breaks between Fig. and the corresponding number. BTW: there's also packages like cleveref which you might want to consider http://tex.stackexchange.com/q/36295/5049 – cgnieder Apr 15 '15 at 09:14

2 Answers2

2

So you want \fref to behave like a regular \ref command. TXS infers the semantics of a command from .cwl files. See the FAQ and the manual.

  • create a file user.cwl in your settings directory with the content \fref{label}#r
  • open TeXstudio and check user.cwl at Options -> Completion.
Tim Hoffmann
  • 11,159
  • Yes! that does exactly what I want, thank you! From reading the manual there doesn't seem to any way to limit the possible labels that come up, such as only the ones beginning with eqn:. Is this correct? – Mauvai Apr 17 '15 at 13:29
  • This is correct. Labels cannot be filtered. – Tim Hoffmann Jul 18 '16 at 20:56
0

In TexStudio you can define a macro which suits your interests: Defining New ShortCuts in TexStudio

and you can put a placeholder in it: How to put placeholder in macros in TexStudio