2

Is there an option in TeXstudio to get from a command to its definition? (similar to Visual Studio's F12 or PyCharm's Ctrl+B)

For example, I have the source line:

\input{other.tex}

The \equat{} is: $\varx + \vary = 0$

And in other.tex file I have:

\newcommand{\equat}{\text{Important Equation}}
\newcommand{\varx}{\text{$x$}}
\newcommand{\vary}{\text{$y$}}

And I want to navigate from \equat{}to its definition in other.tex file, preferably with keyboard shortcut.

  • I understand these are just examples, but they're completely wrong: you cannot do \newcommand{\equation} without getting errors; you cannot define commands such as \var1 and \var2. And defining something as \text{$x$} is really wrong. – egreg Jul 13 '22 at 10:09
  • 3
    What @egreg is saying is true. However, to provide an answer to your question: If you hold Ctrl (maybe Command on Mac?) and click on a macro in your document, TeXstudio should take you to its definition. – Gaussler Jul 13 '22 at 10:13
  • @Gaussler that works! Thanks! – user107511 Jul 13 '22 at 11:54
  • @egreg fixed the example so it works. However, why is \text{$x$} really wrong? – user107511 Jul 13 '22 at 11:59
  • 1
    There is no advantage in being able to use \varx in both text and math modes. If you really want to (but you shouldn't), \newcommand{\varx}{\ensuremath{x}} would be the most efficient code. If you use your definition in math mode, TeX has to exit it, typeset four instances of the math mode x and use one of them. – egreg Jul 13 '22 at 12:12
  • I see, now I understand. Thanks @egreg! – user107511 Jul 13 '22 at 12:26

1 Answers1

1

As mentioned in comments, going to a command definition is possible by pressing Ctrl key and clicking the macro in the code.