Defining \tg so it behaves exactly like \sin and \cos?
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}
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 producexxx
in the proper font and automatically add proper spacing on either side when necessary, ...
\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}
If you are typing in Spanish, load \usepackage[spanish]{babel}
and you will have it available.