6

I know there are at least a few ways to enter mathmode in a .tex document, including $ ... $, $$ ... $$, \( ... \), \[ ... \], \ensuremath{}, and maybe more.

Are there other ways to enter mathmode, and what are the differences between all of the possible ways to enter mathmode?

I at least know that the difference between \( ... \) and \[ ... \] is a difference between inline mathmode and display mathmode, respectively.

What are the differences between all of the other methods, and what are the pros and cons of each method? Are some meant to be used in certain cases; for example, are some meant for writing macros and others for actually writing content of the document?

I know that this question provides an answer at least for the difference between \[ ... \] and $$ ... $$, but I am curious to know more about how they are all different and what the pros and cons of each of them in different cases are (e.g., for macros, for content, etc.).

  • 1
  • 2
    all the input modes you mention natively provide handling for only a single line of math. for multi-line display math, it is better to use an environment with \begin{...} ... \end{...} and the ability to break lines with \`. many such are defined by amsmath; check the user documentation: texdoc amsldoc` on a tex live system. – barbara beeton Jul 10 '13 at 13:38
  • Thanks for pointing that out @StevenB.Segletes, though I'm not entirely sure that is what I'm after. The answer to that question only really explains how \ensuremath{} and $ ... $ (can) interact with one another. I'm interested in an explicit comparison of the different ways of entering mathmode, what they do, how they differ, and best practices for using the different methods. – Adam Liter Jul 10 '13 at 13:43
11

TeX just has two ways to get into math mode $ for inline math and $$ for display math. $ uses a compressed format designed to go inline within the current text line of the paragraph,linebreaking may happen within the formula after infix binary operators and relations. $$ interrupts the paragraph with vertical space and a (by default) centred display, it uses more vertical space, perhaps most noticeably summation symbols are larger and have limits above and below, but there are small differences in many aspects.

Anyone can define any command that uses one or other of these. For example

\def\bmath{$}
\def\emath{$}

would allow

\bmath \alpha^2 \emath

So \(, \[ and \ensuremath that you mention are defined in the LaTeX format, which also defines \begin{math}, \begin{equation}, \begin{displaymath}, \begin{eqnarray}. But many packages define many other macros that use $ or $$ internally. In particular the amsmath package defines many environments such as align. If you include such packages there is no way of discussing "all ways" to get in to math mode: there are an unlimited number of ways.

  • So what are the differences between $ and $$ then? – Dan Jul 10 '13 at 18:27
  • @Dan I added some words about $ and $$ – David Carlisle Jul 10 '13 at 18:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.