Skip to content

Latest commit

 

History

History
2214 lines (1750 loc) · 78.1 KB

05-latex-commands.md

File metadata and controls

2214 lines (1750 loc) · 78.1 KB
date title slug toc_max_heading_level
Last Modified
LaTeX Commands
/mathfield/reference/commands/
2
Mathfields support over **800** LaTeX commands. **To find the name of the LaTeX command matching the shape of a symbol you can draw**, use **Detexify**

To enter a LaTeX command in mathfield press the ESC key or \
to enter LaTeX editing mode. Press ESC to exit LaTeX editing mode.

To examine the LaTeX code for an expression, select it, then press ESC.

The most common symbols can be entered using **keyboard shortcuts**.

Text Zone, Math Zone and Math Style

Math Zone

When in a Math Zone, the content is laid out using typesetting rules specific to math.

For example, variables such as $x$ are displayed in italics, an appropriate amount of space is inserted around some letters such as $ f $ to improve their legibility, and white spaces are ignored.

In a Math Zone, the layout and size of some math elements is adjusted based on the context in which they are used. For example, superscripts and subscripts are displayed using a smaller font size: $ 2^2 $.

Inside a Math Zone, the Math Style indicate the size of the font used to display the content, and some layout options, such as placement of the limits of a sum or integral.

To override the default Math Style, use the following commands:

Math Style
\displaystyle

For equations in their own paragraph/block
\displaystyle \sum_{i=0}^n \frac{a_i}{1+x} $$\displaystyle \sum_{i=0}^n \frac{a_i}{1+x} $$
\textstyle

Confusingly, for inline math, not for text content
\textstyle \sum_{i=0}^n \frac{a_i}{1+x} $$\textstyle \sum_{i=0}^n \frac{a_i}{1+x} $$
\scriptstyle

For subscripts and superscripts
\scriptstyle \sum_{i=0}^n \frac{a_i}{1+x} $$\scriptstyle \sum_{i=0}^n \frac{a_i}{1+x} $$
\scriptscriptstyle

For subscripts and superscripts of subscripts and superscripts
\scriptscriptstyle \sum_{i=0}^n \frac{a_i}{1+x} $$\scriptscriptstyle \sum_{i=0}^n \frac{a_i}{1+x} $$

Text Zone

To include some textual content, use the \text{} or \textrm{} commands to switch to a Text Zone. Inside a Text Zone, white spaces are preserved and the spacing of characters is not adjusted.

The \text{} command will use the font defined by the CSS font-family property of the enclosing mathfield. The size of the text will adjust depending on the current math style (smaller in superscript/subscript).


The \textrm{} command works like \text{} but will use a serif (roman) font.


The \mbox{} command uses the same font as \text but its size does not account for the current math style.


The \textnormal{} command works like \text{}. But it's longer to type.

When in a Text Zone, use $...$ to switch back to an Inline Math Zone or \\[...\\] to switch to a Display (block) Math Zone.

Fractions and Binomials

The \frac command is used to represent a fraction. The first argument is the numerator, the second argument is the denominator. It will size itself according to the current math style (display, text (inline), script, scriptscript). The \dfrac and \tfrac commands force the math style to be display or text (inline) style respectively.

The \cfrac (continuous fraction) command has an optional argument, [l] or [r], that controls if the numerator is left-aligned or right-aligned.

The \pdiff command is a convenient shortcut for partial differentials.


The \binom command is used to represent a binomial coefficient. The \dbinom and \tbinom commands force the math style to be display or text (inline) style respectively.

:::warning[Deprecated]

The following commands are supported but their usage is generally discouraged when creating modern LaTeX content.

:::

Binary Operators

Some binary operators can also be used as a unary operator: +, -, etc... Their spacing is adjusted accordingly. For example in \( -1-2 \) there is less space between - and 1 than there is between - and 2.




Functions

Trigonometry

Non-Standard Trig Functions

The commands in this section are not part of the standard LaTeX distribution but are available in some packages. Use them with caution as they may not be supported by all LaTeX engines. Consider using \operatorname{} instead.

Bounds

Projections

Modulo

Custom Functions

To define a custom function use the \operatorname{} command: the name of the function will be displayed in upright font and with the appropriate spacing.

Unicode

If a symbol is not available as a LaTeX command, you can use the Unicode codepoint of the character. The commands below can be used to insert a Unicode character in a mathfield.

Command
\unicode{} The argument is a Unicode codepoint expressed as a number. To use a hexadecimal number, start the argument with x or " and use uppercase A-F for hexadecimal digits.
  • $$\Large\unicode{10775} $$ \unicode{10775}
  • $$\Large\unicode{"2A17}$$ \unicode{"2A17}
  • $$\Large\unicode{x2A17}$$ \unicode{x2A17}
\char The argument is also a Unicode codepoint, but the {...} delimiters are optional when using ".
  • $$\Large\char"2A17 $$ \char"2A17
^^
^^^^
Followed by 2 or 4 hexadecimal digits with lowercase a-f to specify a Unicode codepoint.
  • $$\Large^^4a $$ ^^4a
  • $$\Large^^^^2a17 $$ ^^^^2a17

:::info[Note] The codepoint of the Unicode character ⨗ U+2A17 INTEGRAL WITH LEFTWARDS ARROW WITH HOOK is 10775 in decimal, 2A1716 in hexadecimal. The codepoint of the letter J is 004A16 in hexadecimal. Learn more about Mathematical Operators and Symbols in Unicode on Wikipedia. :::

Large Operators

Large operators display their limits above and below or adjacent to the operator, depending on the math style (Display Style or Text Style) and on the operator.

The position of the limits can be controlled with \limits, \nolimits or \displaylimits after the operator. The \limits command forces the display of the limits above and below the operator, \nolimits forces the display of the limits adjacent to the operator, and \displaylimits uses an automatic position, based on the operator and current math style.

\limits \nolimits \displaylimits
$$\sum_{i=0}^n\limits $$ $$\sum_{i=0}^n\nolimits $$ $$\sum_{i=0}^n\displaylimits $$
\sum_{i=0}^n\limits \sum_{i=0}^n\nolimits \sum_{i=0}^n\displaylimits
$$\int_0^\infty\limits $$ $$\int_0^\infty\nolimits $$ $$\int_0^\infty\displaylimits $$
\int_0^\infty\limits \int_0^\infty\nolimits \int_0^\infty\displaylimits

In Display Style, the \intop and \ointop commands display their limits above and below by default, while the \int command display its limit adjacent.


Logic

Quantifiers

Unary/Binary Operators

Relational Operators

Arrows

Negated Arrows

Extensible Arrows

The length of the arrow commands above is fixed. The length of the commands in this section is determined by the length of the content above and below the arrows, which is specified as an argument (and optional argument):

<Latex value='\xrightarrow[\text{long text below}]{}'flow='column'/> <Latex value='\xrightarrow{\text{long text above}}'flow='column'/> <Latex value='\xrightarrow[\text{and below}]{\text{long text above}}'flow='column'/>