rstudio / bookdown

Authoring Books and Technical Documents with R Markdown
https://pkgs.rstudio.com/bookdown/
GNU General Public License v3.0
3.78k stars 1.27k forks source link

Support the $$ syntax for pdf output #959

Open etiennebr opened 4 years ago

etiennebr commented 4 years ago

This is a feature request for $$ support for pdf output. I'm moving the discussion from https://github.com/rstudio/rticles/issues/326

For epub, the syntax seems to be supported:

$$
(\#eq:label)
math
$$

It would be nice to have it for pdf too.

Because the $$ notation is closely related to cross-referencing of numbered equations, I think it's relevant to expose the cross-reference package syntax.

The cross-reference pandoc filter uses

$$ math $$ {#eq:label}

Translated to

\begin{equation}
\label{eq:label}
math 
\end{equation}

for tex output

This is slightly different from the current solution, which is to use a syntax closer to latex

\begin{equation}
(\#eq:label)
math 
\end{equation}

This prevents equation previews in Rstudio, and also requires the user to learn a new syntax when outputting to pdf.


By filing an issue to this repo, I promise that

I understand that my issue may be closed if I don't fulfill my promises.

cderv commented 4 years ago

Some thoughts:

::: {.equation #eq1} math :::

that would lead to the a new equation environment in latex
```latex
\begin{equation}
\label{eq:eq1}
math 
\end{equation}
jiedxu commented 3 years ago

I hope there is a way in #940 syntax to label one of the equations in a aligned, align or any multi-line math environment:

$$ \begin{aligned}
math 1 \nonumber \\
math 2 (\#eq:label)
\end{aligned} $$
cderv commented 2 years ago

More thoughts:

Afterall the following syntax could be the simpler to implement

$$ 
math
$$ {#eq:label}

using lua filter maybe

❯ pandoc -t native
$$ math $$ {#eq:label}
^Z
[ Para
    [ Math DisplayMath " math " , Space , Str "{#eq:label}" ]
]