bookdown icon indicating copy to clipboard operation
bookdown copied to clipboard

Support the $$ syntax for pdf output

Open etiennebr opened this issue 3 years ago • 3 comments

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

  • [x] I have fully read the issue guide at https://yihui.org/issue/.
  • [x] I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('bookdown'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('rstudio/bookdown').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • [x] I have learned the Github Markdown syntax, and formatted my issue correctly.

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

etiennebr avatar Sep 27 '20 14:09 etiennebr

Some thoughts:

  • This would be in favor of rethinking the cross referencing in bookdown to maybe do it using a Pandoc Lua filter to deal with several output format.
  • Another idea: We could adapt the future news syntax (#940) so that we could write equation environment this way

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

that would lead to the a new equation environment in latex

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

cderv avatar Sep 27 '20 14:09 cderv

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} $$

edxu96 avatar Aug 17 '21 12:08 edxu96

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}" ]
]

cderv avatar Dec 23 '21 15:12 cderv