0

I have a considerable amount of TeX documents that will be displayed on a website. The problem is, for this specific set of users, trigonometric functions such as \tan{x} are spelled differently - tg x in that case.

So, I approached this issue knowing the following LaTeX command

\providecommand{\tan}{}\renewcommand{\tan}{\hspace{2pt}\mathrm{tg\,}}

Including \, is necessary to render \tan{2x} as tg 2x. However, such addition causes \tan(2x) to be rendered with an unnecessary space before the argument: tg (2x)

How could I conditionally include that \, based on the presence of curly brackets?

nickh
  • 101
  • 2
    As always mathjax is off topic on this site. You will need to ask your question elsewhere. (mathjax does not use latex anywhere) – daleif Aug 12 '20 at 11:29
  • 1
    I'm sorry for the inconvenience. I thought tex.stackexchange would regard anything TeX related... Anyway, I will reformulate my question, as the same problem can be observed in LaTeX. – nickh Aug 12 '20 at 11:33
  • What you need is an operator. Search how to define new math operators. – Sigur Aug 12 '20 at 11:39
  • 1
    https://tex.stackexchange.com/questions/67506/newcommand-vs-declaremathoperator; you'll need to \let\tan\undefined. – Joseph Wright Aug 12 '20 at 11:42
  • 1
    mathjax is not even tex related (as such), it is just a javascript library who can understand a subset of the latex syntax. Redefinition is a good idea if you want to know how to do this in LaTeX, just remember that it might not apply to mathjax afterwards – daleif Aug 12 '20 at 11:45
  • Defining a new math operator worked for me. All the rapid feedback the community gave to my question was much appreciated, thank you! – nickh Aug 12 '20 at 11:53
  • you do not need to use explicit spacing and fonts, mathjax supporrts \DeclareMathOperator from amsmath. – David Carlisle Aug 12 '20 at 18:38

1 Answers1

0

As Sigur stated, the desired behavior is achieved by defining a new math operator. The following command worked as expected:

\providecommand{\tan}{}\renewcommand{\tan}{\mathop{\rm tg}\nolimits}


There's a better, cleaner and more straightforward solution, pointed by David Carlisle: \DeclareMathOperator \tan{tg}

nickh
  • 101