11

In my country, instead of tan, we use tg (this is just one of them). I want to be able to type

\tg{x}

and possibly

\tgx

So that Latex recognizes them. I tried defining them like this:

\DeclareMathOperator{\tg}{\text{tg}}

That seemed to work until I used in a block of bold text and it was bold as well, while \sin and \cos where not bold. So how can I define them correctly?

Edit:

I use this new operator in math blocks, like

The use of $ \tg{x} $

Or even in \subsection (which has a bold formatting in my document):

\subsection{The use od $ \tg{x} $}
8
  • 1
    don't use \text (it will use the right \mathrm font automatically) Jan 28, 2016 at 20:39
  • 5
    then it'll work as you intended, just like \sin so \DeclareMathOperator{\tg}{tg} Jan 28, 2016 at 20:42
  • 1
    +1 for using tg. As you may know, we have been for years in a bad period in France, and especially pessimistic people are characterized as "declinologists", of whom I am probably a representant. What's the relation? the fact that the French more and more use tan for no other reason that it is how it appears on the pocket calculators. Long live the tg of the bygone past!
    – user4686
    Jan 28, 2016 at 21:29
  • 3
    @jfbu I suppose you've gone off on a tangent? :) Jan 28, 2016 at 21:58
  • 2
    According to Cajori, the abbreviation “tan” was used by Finck in 1583; Euler used “tang”, but sometimes “tg”. In the 18th century, “tang” and “tan” were probably the most used abbreviations. A table in the book by Cajori seems to show that “tg” is more German than French; for instance, Legendre and Cauchy used “tang”.
    – egreg
    Jan 28, 2016 at 22:07

3 Answers 3

19

All you need to do is write \DeclareMathOperator{\tg}{tg}; this defines the command \tg to use the normal math font. Then, you can define \tgx to just be \tg x:

\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator{\tg}{tg}
\newcommand{\tgx}{\tg x}
\begin{document}
In a paragraph of normal text, $\sin x$, $\cos x$, $\tg x$, and $\tgx$.

\textbf{
In a paragraph of bold text, $\sin x$, $\cos x$, $\tg x$, and $\tgx$.
}
\end{document}

enter image description here

6

When you declare a math operator, you should do so without specifying it as being formatted as \text. There is no mention of this requirement in the amsmath user guide (section 5.1 Defining new operator names):

To define a math function \xxx to work like \sin, you write

\DeclareMathOperator{\xxx}{xxx}

whereupon ensuing uses of \xxx will produce xxx in the proper font and automatically add proper spacing on either side when necessary, ...

enter image description here

\documentclass{article}

\usepackage{amsmath}

\DeclareMathOperator{\tg}{tg}

\begin{document}

$\sin^2\theta + \cos^2\theta = 1$

$\tg^2\theta + \cos^2\theta = 1$

{\bfseries $\tg^2\theta + \cos^2\theta = 1$}

\end{document}
5

If you are typing in Spanish, load \usepackage[spanish]{babel} and you will have it available.

4
  • It's Romanian actually :)
    – Victor
    Jan 28, 2016 at 20:42
  • 1
    Argh, I didn't know it was used elsewhere.
    – Manuel
    Jan 28, 2016 at 20:43
  • 1
    it used to be in use in France, but sadly we are not as robust as the Romanians !
    – user4686
    Jan 28, 2016 at 21:30
  • @Manuel also in Russia and most other post-USSR countries.
    – ScumCoder
    Sep 13, 2016 at 19:03

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.