Tag Info

Hot answers tagged

68

There are many differences. The main one is in the fact that \mathrm{xyz} behaves like an ordinary letter, while \operatorname{xyz} behaves like function names such as \sin. Here's an illustration $\sin x + \sin(x+y) + a\sin z$ $\mathrm{sin} x + \mathrm{sin}(x+y) + a\mathrm{sin}z$ where it's clear that the second line is wrongly typeset. Even if your ...


51

I've found an answer in a usenet post by Heiko Oberdiek and another by Donald Arseneau. Improved code thanks to shiznick. The issue is that \left and \right introduces an inner atom (see The TeXbook, chapter 18, section 4), which has different spacing rules than ordinary atoms, produced by ( and ) (and the other delimiters). To remove this spurious ...


47

As Pieter says in his comment, \DeclareMathOperator*{\argmin}{arg\,min} is indeed the correct LaTeX way to do that. This requires \usepackage{amsmath} (actually amsopn would be sufficient, it's automatically loaded by amsmath which is recommended for math typesetting anyway). Note: the * that follows \DeclareMathOperator sets the underscored option (the ...


46

There is a standard: it should be upright, not italicized. Read Typesetting mathematics for science and technology according to ISO 31/XI I suggest using the commath package to correctly typeset differentials.


35

the xlop package does this sort of thing. It does warn that it uses "french conventions", but at least for multiplication it looks fine, to me. disclaimer: i last did multiplication sums in school in the 1950s... \documentclass{article} \usepackage{xlop} \begin{document} \opmul{384}{56}\qquad \end{document}


35

When is it better to use \operatorname (or its wrapper \DeclareMathOperator) instead of \mathop? The answer is easy: always, unless you know precisely what's the behavior of \mathop. First of all, one must of course recall that \operatorname and \DeclareMathOperator are provided by the amsopn package, which is automatically loaded by amsmath, but is also ...


33

You have been told how to get a curved L. But here's some more general advice, which also applies in this situation: In cases such as this, always create your own shortcut macro, say \newcommand{\Lagr}{\mathcal{L}} This way, if you ever decide that that curly L is not quite the one you like, it is easy to switch. Also, even before you knew the answer to ...


31

I'd say it really depends on the context. As Emre pointed out, there's an ISO standard; according to wikipedia, ISO 31-11 was superseded in 2009 by ISO 80000-2. The latter carries the title "Quantities and units -- Part 2: Mathematical signs and symbols to be used in the natural sciences and technology". As a mathematician I think: Why should I use the same ...


30

\DeclareMathOperator is designed to create commands that should typeset operator names such as sin and lim. Some of these are already defined in base TeX or LaTeX so one writes 2\sin\theta instead of 2sin\theta giving correct spacing and font. If you need an operator of this type that is not predefined, then you create it with \DeclareMathOperator, ...


27

Operators such as \sum are not defined with \DeclareMathOperator that should be used (with or without a *) for “textual” operators. The definition of \sum is \DeclareMathSymbol{\sum}{\mathop}{largesymbols}{"50} that becomes, internally, \mathchardef\sum="1350 The macro \DeclareMathOperator uses \mathop, which has a strange property: if its argument ...


27

The package cancel can draw a diagonal line. \documentclass[a4paper]{article} \usepackage{amsmath} \usepackage{cancel} \begin{document} $\cancel{\mathcal{R}}$ \end{document}


27

Updated solution using the features of etoolbox which has essentially implemented the “\MapCommand” and named it \forcsvlist \documentclass{article} \usepackage{amsmath} \usepackage{etoolbox} \newcommand{\DeclareMyOperator}[1]{% \expandafter\DeclareMathOperator\csname #1\endcsname{#1} } \newcommand{\DeclareMathOperators}{\forcsvlist{\DeclareMyOperator}} ...


26

You should place the expression in the subscript, as shown below. Most LaTeX books explain this. \documentclass{article} \begin{document} Display mode: \[ \max_{1 \leq j \leq n} \] Inline mode: $\max_{1 \leq j \leq n}$, $\max\limits_{1 \leq j \leq n}$. \end{document} Note how I used \limits to force the subscript under the operator in inline mode (if ...


25

these two-part operators have to be declared as operators to get the correct spacing on either side. the following definitions will take care of that, while forcing each individual part to be treated as an ordinary character. \newcommand{\pluseq}{\mathrel{{+}{=}}} \newcommand{\minuseq}{\mathrel{{-}{=}}} the result may still not be to your liking, but if ...


23

I assume, the replacements should be done in math mode only. Then the starting characters can be made active via a special value "8000 for \mathcode. The characters behave in text mode as usual, but they became special in math mode. The following example document provides parsers for the following shorthands: << : \ll (latexsym/amsmath) <> : ...


22

There are several ways to do it using different programming facilities of different packages. Here's what it looks like using the LaTeX2e kernel command \@for to map over a comma-separated list: \makeatletter \newcommand\MakeMathOperators[1]{% \@for\@ii:=#1\do{% \expandafter\DeclareMathOperator\@ii }% } \makeatother \MakeMathOperators{ \rep {Rep} ...


22

tl,dr: It's complicated, but be consistent. I believe the answers here tend to miss the point. While Emre mentions that there is an international norm regarding typesetting mathematics that is very explicit about this topic, Hendrik Vogt makes the right argument, but doesn't take it far enough. This question doesn't have an answer as simple as yes or no, ...


22

\not is designed for negating relation symbols basically as wide as the equals sign. But it doesn't always work and, for instance, one should use \notin rather than \not\in because the membership sign is too high. Here's a possible solution for your “negated relations”: \documentclass{article} \usepackage{xparse} \NewDocumentCommand{\calrel}{sm} {% ...


22

\mathop allows you to perform operator-related things (like sub-/superscripting underneath/over top in display style) on non-operator symbols: \documentclass{article} \begin{document} \[ \mathop{\sum\sum}_{i\neq j} \] \end{document} Using amsmath, it is also possible to declare a new operator, say \sumsum, if you're using this notation on a more ...


21

mathrm: It is like math mode (no spaces), but in upright mode. The font size isn't changed. \operatorname: The argument is written in upright mode but with some additional space before and behind. The following example shows the differences: \documentclass[]{article} \usepackage{amsmath} \begin{document} \[x\operatorname{foo}y\] \[x\mathrm{foo}y\] ...


21

\newcommand{\periodplus}{\mathbin{{.}{+}}} \( a=b\periodplus 1 \) TeX (and so LaTeX) doesn't interpret spaces in the code for math formulas, but relies on its predefined rules. For TeX a, . and b represent "ordinary" symbols and + a binary operation symbol. Consecutive ordinary symbols are set without any space between them; instead, the combination ...


20

You may try with the following code: \documentclass{article} \usepackage{mathtools} \newcommand{\Rint}{\mathop{\mathrlap{\pushR}}\!\int} \newcommand{\pushR}{\mathchoice {\mkern2.5mu R} {\scriptstyle R} {\scriptscriptstyle R} {\scriptscriptstyle R} } \begin{document} \[ \left|\Rint_a^b f\right|\textstyle\left|\Rint_a^b f\right|_{\left|\Rint_a^b ...


19

Something like: \mathop{\sum_{j=1}^{\infty}\sum_{k=1}^{\infty}}_{j>k} maybe? Looks like this: Or if you want it on the same line as j=1 and k=1, then maybe: \mathop{\sum^{\infty}\sum^{\infty}}_{j=1\ j>k\ k=1}


19

Alternatively, if you are using any of the packages from the AMS (amsart.cls or amsmath.sty) then there is a command \DeclareMathOperator which does what it says on the tin! For example, \DeclareMathOperator{\Det}{Det} I think that it can handle variants, but I don't recall off the top of my head.


19

Probably I don't have the precedence rules exactly as you need, but something like \def\p{0} \def\power#1#2{% \ifnum\p>20(\fi {\def\p{20}#1}^{\def\p{0}#2}% \ifnum\p>20)\fi} \def\product#1#2{% \ifnum\p>20(\fi {\def\p{20}#1#2}% \ifnum\p>20)\fi} \def\add#1#2{% \ifnum\p>10(\fi {\def\p{10}#1+#2}% \ifnum\p>10)\fi} \def\subtract#1#2{% ...


18

The scalerel package allows you to scale a symbol to the size (and vertical positioning) of another symbol. So in this case, I define \foo to scale \maltese to the size of \sum. Thus, it piggybacks its sizing off the well defined behavior of \sum. It wasn't clear to me if the questioner wanted to keep the maltese cross the same size in all operations. ...


17

Use \DeclareMathOperator or its starred form (if the operator should take limits): \usepackage{amsmath} % \DeclareMathOperator{<command>}{<text>} % if the operator shouldn't take limits \DeclareMathOperator\ext{ext} % if the operator should take limits % \DeclareMathOperator*\ext{ext}


17

There are a variety of spacing techniques in math mode that you could consider. The following is taken verbatim from Herbert Voss' Mathmode document on horizontal alignment. It showcases the different types of spacing available and compares them very well: \documentclass{article} \usepackage{amsmath} \begin{document} % Taken from ...


17

I'd propose $a\mathrel{-}=1$ For a general purpose macro, define \newcommand{\assign}[2]{% \mathrel{#1}\mathrel{#2}% } so that you can call $a \assign{-}{=} 1$ $a \assign{=}{+} 1$ $a \assign{++}{=} 1$


16

The package mathtools has implemented a general solution for that problem. It defines the command \DeclarePairedDelimiter that you can use as follows: \DeclarePairedDelimiter\parentheses{\lparen}{\rparen}. With this single declaration you have a new powerful command for several cases: \parentheses{x} just replaces $(x)$ \parentheses*{x} will do the right ...



Only top voted, non community-wiki answers of a minimum length are eligible