Skip to main content
replaced http://tex.stackexchange.com/ with https://tex.stackexchange.com/
Source Link

For Corr, Cov and Var I usually use \DeclareMathOperator{\Corr}{Corr}, which, done once in an answer, allows me to just write \Corr(X,Y) whenever I need it later, which displays:

$$\DeclareMathOperator{\Corr}{Corr} \Corr(X,Y)$$

Like Amoeba's answer, this ensures spacing is done correctly in a way that \mathrm doesn't. But see newcommand vs. DeclareMathOperatornewcommand vs. DeclareMathOperator on TEX.SE: Amoeba's answer apparently has the advantage that newcommand gives more flexibility.

But note I can still do \DeclareMathOperator{\E}{\mathbb{E}} \E(X,Y) and produce:

$$\DeclareMathOperator{\E}{\mathbb{E}} \E(X,Y)$$

And of course I can reuse these in a later piece of $\LaTeX$ too: $\E(X)+\Corr(X,Y)$

(In a document DeclareMathOperator can only be used in a preamblecan only be used in a preamble but this doesn't seem to cause any difficulty on here.)

For Corr, Cov and Var I usually use \DeclareMathOperator{\Corr}{Corr}, which, done once in an answer, allows me to just write \Corr(X,Y) whenever I need it later, which displays:

$$\DeclareMathOperator{\Corr}{Corr} \Corr(X,Y)$$

Like Amoeba's answer, this ensures spacing is done correctly in a way that \mathrm doesn't. But see newcommand vs. DeclareMathOperator on TEX.SE: Amoeba's answer apparently has the advantage that newcommand gives more flexibility.

But note I can still do \DeclareMathOperator{\E}{\mathbb{E}} \E(X,Y) and produce:

$$\DeclareMathOperator{\E}{\mathbb{E}} \E(X,Y)$$

And of course I can reuse these in a later piece of $\LaTeX$ too: $\E(X)+\Corr(X,Y)$

(In a document DeclareMathOperator can only be used in a preamble but this doesn't seem to cause any difficulty on here.)

For Corr, Cov and Var I usually use \DeclareMathOperator{\Corr}{Corr}, which, done once in an answer, allows me to just write \Corr(X,Y) whenever I need it later, which displays:

$$\DeclareMathOperator{\Corr}{Corr} \Corr(X,Y)$$

Like Amoeba's answer, this ensures spacing is done correctly in a way that \mathrm doesn't. But see newcommand vs. DeclareMathOperator on TEX.SE: Amoeba's answer apparently has the advantage that newcommand gives more flexibility.

But note I can still do \DeclareMathOperator{\E}{\mathbb{E}} \E(X,Y) and produce:

$$\DeclareMathOperator{\E}{\mathbb{E}} \E(X,Y)$$

And of course I can reuse these in a later piece of $\LaTeX$ too: $\E(X)+\Corr(X,Y)$

(In a document DeclareMathOperator can only be used in a preamble but this doesn't seem to cause any difficulty on here.)

Source Link
Silverfish
  • 23.9k
  • 22
  • 36

For Corr, Cov and Var I usually use \DeclareMathOperator{\Corr}{Corr}, which, done once in an answer, allows me to just write \Corr(X,Y) whenever I need it later, which displays:

$$\DeclareMathOperator{\Corr}{Corr} \Corr(X,Y)$$

Like Amoeba's answer, this ensures spacing is done correctly in a way that \mathrm doesn't. But see newcommand vs. DeclareMathOperator on TEX.SE: Amoeba's answer apparently has the advantage that newcommand gives more flexibility.

But note I can still do \DeclareMathOperator{\E}{\mathbb{E}} \E(X,Y) and produce:

$$\DeclareMathOperator{\E}{\mathbb{E}} \E(X,Y)$$

And of course I can reuse these in a later piece of $\LaTeX$ too: $\E(X)+\Corr(X,Y)$

(In a document DeclareMathOperator can only be used in a preamble but this doesn't seem to cause any difficulty on here.)