5

I have been answering questions on Math S.E as well as Physics S.E.
Today I was pointed out for using \mathrm instead of using \sin by a fellow user.

So my question stands that, which of them is more visually appropriate for a reader and more acceptable:

1. $\sin t$

2. $\mathrm{sin}\ t$

as represented below:

sinsinati

To me, both of them look the same, what's the rendering difference (any helpful documentation)?

  • 8
    $\sin t$. It's easier, and TeX knows that it is an operator, so the spacing is better. Try for example to typeset $\sin^{2} t$. – Rmano Aug 10 '20 at 18:10
  • 3
    Also try $x\sin t$ versus $x \mathrm{sin}\ t$. Spacing is way different. \sin t is designed to produce the "proper" spacing. \mathrm{sin} is just a simple math atom, whereas \sin spaces like a math operator. – Steven B. Segletes Aug 10 '20 at 18:10
  • The space between the sin and t are a bit smaller with the correct \sin t because \sin is not only in mathrm but is also defined as a math operator. – Herb Schulz Aug 10 '20 at 18:13
  • 5
    Note that Math.SE and Physics.SE do not literally use (La)TeX for maths typesetting, they use MathJax, which supports TeX-like input, but does not process the formulae with TeX. There may be some small differences in details between MathJax and real TeX and it is not completely inconceivable that these differences come to light in a setting like this. The answers you will get here will quite probably focus on (La)TeX and may be slightly different from what MathJax gives you (MathJax is generally considered off-topic here). – moewe Aug 10 '20 at 18:18
  • \mathrm{sin}\ x and \sin{t} look same (Indentation as well) – Anindya Prithvi Aug 10 '20 at 18:32
  • @moewe I have considered that as well, but it seems to me that my mathrm version (which has proper indent) is the fullform of \sin{t} ....is it the case? – Anindya Prithvi Aug 10 '20 at 18:33
  • @StevenB.Segletes yes, and the "sin" when looked closely also looks different, is there a proper script documentation available on it? – Anindya Prithvi Aug 10 '20 at 18:35
  • 1
    Leslie Lamport's book, "LaTeX: A document Preparation System" talks about math operators, including \sin on p.44-45. As to the font itself, I would not see a reason why it would be different, if that is what you are implying. – Steven B. Segletes Aug 10 '20 at 18:40
  • 3
    The LaTeX standard definition of \sin is a bit more complicated than \mathrm{sin}. It follows the math operators explained in https://tex.stackexchange.com/q/84302/35864 – moewe Aug 10 '20 at 18:45
  • @StevenB.Segletes Yes I exactly imply that – Anindya Prithvi Aug 10 '20 at 18:45
  • @moewe probably just what am looking for, thanks, I'll have a look – Anindya Prithvi Aug 10 '20 at 18:46
  • 1
    Standard LaTeX has \DeclareRobustCommand\sin{\mathop{\operator@font sin}\nolimits} but most people will use amsmath which has \def\sin{\qopname\relax o{sin}} and then you need to chase \DeclareRobustCommand{\qopname}[3]{% \mathop{#1\kern\z@\operator@font#3}% \csname n#2limits@\endcsname} – moewe Aug 10 '20 at 18:47
  • 1
    "What does it look like" is a red herring. $\mathrm{s}\phantom{hello general Kenobi}\mathrm{in}\ t$ looks the same as your two options visually, but you'd be (correctly) reprimanded for using it. Clean coding, searchability, etc. also play a role. – Federico Poloni Aug 11 '20 at 13:15
  • 1
    By the way, I keep seeing |\sin x| which typesets badly and should be \lvert\sin x\rvert – egreg Sep 01 '20 at 21:55

2 Answers2

21

Compare:

\documentclass{article}
\begin{document}
\[ x\sin^{2} (t) + x\cos^{2} (t) = x\]
\[ x\mathrm{sin}^{2}\ (t) + x\mathrm{cos}^{2}\ (t) = x\]
\end{document}

enter image description here

in my opinion, the first option is much clearer.

Rmano
  • 40,848
  • 3
  • 64
  • 125
  • aa, noo, add an escape sequence before xsin^2 – Anindya Prithvi Aug 10 '20 at 18:29
  • x\ \sin^2{t} like this – Anindya Prithvi Aug 10 '20 at 18:30
  • If you look minutely, there's a difference between character width too, but does latex uses a different script for this?? – Anindya Prithvi Aug 10 '20 at 18:37
  • 17
    @AnindyaPrithvi The idea is that proper math spacing is a difficult matter that requires a lot of work if done manually; however it follows a (not very easy) set of rules, which are so hardwired in TeX; using \sin exploits the rules and you have not to worry about adding spaces manually. – egreg Aug 10 '20 at 20:28
  • 5
    Indeed, OP, if you ever write TeX with another co-author, you will cause them so many headaches if you use cumbersome, imperfect, and easy to get wrong versions of standard commands like this. – Greg Martin Aug 11 '20 at 07:51
  • Small nitpick: when using parentheses for the argument, there shouldn't be a space between sin/cos and the parentheses, or at least it should be smaller. – Javier Aug 11 '20 at 13:54
  • why did you put explicit spaces "\ " in the second formula but not the first? makes for a useless comparison... – peter Dec 26 '20 at 19:09
  • i dont get it. they shouldn't be there or at least they should be on both versions. what sense does it make to compare two things that were manually made different? – peter Dec 26 '20 at 19:20
  • @peter please look at the question. The extra \ space is in the question, so I answered using the question as a base, comparing between them. If you think that's not the correct way, you are free to add another answer. – Rmano Dec 26 '20 at 19:42
  • you're right, im sorry. i forgot that aspect and thought it was only about \mathrm{sin} vs \sin. my bad. – peter Dec 26 '20 at 19:56
  • @peter no problem – Rmano Dec 26 '20 at 19:57
4

Considering also my registration on Math.SE., any user can adopt the long notation \operatorname{...} (eq. n. (3)) which provides the same white spaces as the formula n. (2). \operatorname{...} can be used to define any mathematical operator, with the correct spaces, when yo're using MathJaX.

You can observe that the (2) (it has been used \sin and \cos operators) and for the (3) \operatorname{...} and they are the same. It is visible that using \mathrm{sin} with severals \, you have note the correct blank spaces.

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath,amssymb}
\usepackage{xcolor}

\begin{document} \noindent Limited spaces for the operators: [\color{red}{\mathrm{sin}(\alpha+\beta)=\mathrm{sin}\alpha\mathrm{cos}\beta+\mathrm{cos}\alpha\mathrm{sin}\beta} \tag{1}] Correct spaces for the operators: [\color{green}{\sin(\alpha+\beta)=\sin\alpha\cos\beta+\cos\alpha\sin\beta} \tag{2}] Correct spaces for the operators: same of the previous code: [\color{green}{\operatorname{sin}(\alpha+\beta)=\operatorname{sin}\alpha\operatorname{cos}\beta+\operatorname{cos}\alpha\operatorname{sin}\beta} \tag{3}] Additional spaces given by the control \verb| \ | showing a bad spacing: [\color{red}{\mathrm{sin}(\alpha+\beta)=\mathrm{sin} \ \alpha \ \mathrm{cos} \ \alpha+ \mathrm{sin}\ \alpha \ \mathrm{cos} \ \alpha}\tag{4}] \end{document}

enter image description here

Sebastiano
  • 54,118