Skip to content

Commit

Permalink
more on math rules following yihui/xfun@1a57975 and #34
Browse files Browse the repository at this point in the history
  • Loading branch information
yihui committed Oct 10, 2024
1 parent 254eda9 commit 8f17dee
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions docs/02-syntax.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,13 @@ x &\text{if } x \geq 0 \\

For expressions in pairs of single or double dollar signs to be recognized as
LaTeX math, there must be no spaces after the opening dollar sign, or before the
closing dollar sign. There should be at least one space before the opening
dollar sign, unless the math expression starts from the very beginning of a
line.
closing dollar sign. The math expression should either start from the very
beginning of a line, or have a space or `(` before the opening dollar sign.

- For a pair of single dollar signs, they must be on the same line in the
text, and the closing dollar sign should not be followed by a number (to
avoid detecting math mistakenly from text like "a \$5 bill and a \$10
bill").
bill"). The inner math expression should not be wrapped in backticks.

- For `$$ $$` expressions, they can span over multiple lines, in which case
the closing `$$` must have at least one non-space character before it, and
Expand All @@ -80,6 +79,7 @@ Valid examples:

``` tex
$x + y$
($x + y$)
$x + y$
text $x + y$ text
Expand All @@ -93,16 +93,17 @@ $$x +
Invalid examples:

``` md
$ x + y$ (space after the opening `$`)
text$x + y$ (lack of space before the opening `$`)
text $x + y$10 text (number after closing `$`)
$ x + y$ <- space after the opening `$`
text$x + y$ <- lack of space before the opening `$`
text $x + y$10 text <- number after closing `$`
$x +
y$ (`$ $` expressions cannot be written on multiple lines)
y$ <- multi-line `$ $` expressions
$`x + y`$ <- expression wrapped in backticks

$$x +
y
$$
(lack of non-space character before closing `$$`)
^- lack of non-space character before closing `$$`
```

LaTeX math environments are also supported, e.g., below are an `align`
Expand Down

0 comments on commit 8f17dee

Please sign in to comment.