I am using TexStudio and define some personal commands with \DeclareRobustCommand{\foo}{bar}. Unfortunately my TexStudio does not recognize \foo as a new command. Thus I had the idea to write

\DeclareRobustCommand{\foo}{bar} \let\foo\foo

Now TexStudio recognizes \foo as a command. I want to ask, if the construction \let\foo\foo has some drawbacks or is forbidden for some reason.

  • 1
    Well, this works and has no drawbacks, as far as I know, but the question should be rather: Why does TeXStudio not recognize macros being defined with \DeclareRobustCommand ? – user31729 Jan 7 '18 at 10:59
  • No problem as far as I can see; but wouldn't it be better to ask TeXStudio maintainers to add support for such standard constructions? – egreg Jan 7 '18 at 10:59
  • 1
    To be on the 'safe' side: \DeclareRobustCommand{\foohelper}{bar} \let\foo\foohelper – user31729 Jan 7 '18 at 11:00
  • @ChristianHupfer better would be \let\foo\relax\DeclareRobustCommand{\foo}{bar}, imho. – Skillmon Jan 7 '18 at 12:28

I see no problem whatsoever for \DeclareRobustCommand with my version of TeXStudio

enter image description here

The problem appears with \NewDocumentCommand, instead, but the solution is not using \let\fooNDC\fooNDC, but rather \providecommand. Indeed, if I add the \let, the orange background doesn't disappear.

enter image description here

Of course, asking for TeXStudio support would be the best solution. By the way, TeXStudio recognizes \NewDocumentCommand as soon as \usepackage{xparse} is scanned, but not commands defined with it. Probably it's an easy fix for the developers.

enter image description here

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.