TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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} $}
share|improve this question
    
don't use \text (it will use the right \mathrm font automatically) – David Carlisle Jan 28 at 20:39
    
@DavidCarlisle then what? – Victor Jan 28 at 20:40
5  
then it'll work as you intended, just like \sin so \DeclareMathOperator{\tg}{tg} – David Carlisle Jan 28 at 20:42
2  
@jfbu I suppose you've gone off on a tangent? :) – Arun Debray Jan 28 at 21:58
1  
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 at 22:07
up vote 14 down vote accepted

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

share|improve this answer

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

share|improve this answer
    
It's Romanian actually :) – Victor Jan 28 at 20:42
1  
Argh, I didn't know it was used elsewhere. – Manuel Jan 28 at 20:43
1  
it used to be in use in France, but sadly we are not as robust as the Romanians ! – jfbu Jan 28 at 21:30

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}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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