Closed etiennebr closed 3 years ago
Using base_format: rticles::mdpi_article
as a base format pretty much resolves the issue
output:
bookdown::pdf_book:
base_format: rticles::mdpi_article
But
$$
(\#eq:eq2)
a = c \cdot b
$$
is still rendered to
\[
\label{eq:eq2}
a = c \cdot b
\]
But I guess it's an issue for bookdown
, rather than rticles
.
Hi @etiennebr,
this is indeed the official way for now to add bookdown features to any other format. It is document in the book:
we may in the future move the referencing feature in rmarkdown directly to make it available more broadly without doing this.
So you just need to change the output:
field in the yaml
it seems like the second equation should also be translated to \begin{equation} ... \end{equation}
Pandoc will not do the conversion. It will transform $$
to the bracketed syntax: https://pandoc.org/MANUAL.html#extension-tex_math_dollars
And it seems for bookdown referencing of equation you need to explicitly use \begin{equation}
as described in the documentation https://bookdown.org/yihui/bookdown/markdown-extensions-by-bookdown.html#equations
It seems $$
works for HTML though - Maybe we could support the $$
syntax for pdf output. This is indeed a bookdown issue.
Also, bookdown features is to provided same referencing mechanism for different type of output.
With rticles, the output format is only tex for now so I think it is expected that reference mechanism from tex be used directly maybe.
This is an equation
\begin{equation} \label{eq:1}
c = a \cdot b
\end{equation}
see \ref{eq:1}
But I can see the advantage of having one syntax, and that the equation preview in rstudio works.
@cderv, thanks for all the pointers.
we may in the future move the referencing feature in rmarkdown directly
Is there an issue I can track?
Maybe we could support the $$ syntax for pdf output
Opened #959
Is there an issue I can track?
Not yet. It is just an idea for now. Nothing yet planned. I am referencing issues that points toward that being a good idea. And testing the idea in the wild ! 😉
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.
Equation labels are not translated
\label{eq:eq}
when knitting withmdpi_article
, but they are withbookdown::pdf_document2
.Here's the
Rmd
Knit with
bookdown::pdf_document2
Knit with
rticles::mdpi_article
It seems like there is some processing not happening. I don't have a deep knowledge of
knitr
, so I suspect it might simply be that themdpi_article
andpdf2_document
are unrelated, andmdpi
in fact usespdf_document
for rendering, but in any case, I'd like to reference equations in amdpi
paper, so this might be a feature request. Also, per https://github.com/rstudio/bookdown/issues/190#issuecomment-541709385, it seems like the second equation should also be translated to\begin{equation} ... \end{equation}
(at least for ebooks), so I wondered if one of my packages was outdated, but apparently not (see session info below, but knitr_1.30, rmarkdown_2.3, bookdown_0.20, rticles_0.16.1 all seemed fine).Here are the rendered
.tex
With
bookdown::pdf_document2
yields in.tex
With
rticles::mdpi_article
, thetex
is:@dleutnant, any idea? @cderv, I'm happy to dive a bit deeper in
rticles
/knitr
if you can point me in a general direction where this could be fixed, or how to have a step-by-step look at the knitting process because I'm completely new to this code.session info
```{r} xfun::session_info('rticles') #' R version 3.6.3 (2020-02-29) #' Platform: x86_64-pc-linux-gnu (64-bit) #' Running under: Ubuntu 18.04.5 LTS, RStudio 1.3.1073 #' #' Locale: #' LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C LC_TIME=en_CA.UTF-8 #' LC_COLLATE=en_CA.UTF-8 LC_MONETARY=en_CA.UTF-8 LC_MESSAGES=en_CA.UTF-8 #' LC_PAPER=en_CA.UTF-8 LC_NAME=C LC_ADDRESS=C #' LC_TELEPHONE=C LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C #' #' Package version: #' base64enc_0.1.3 digest_0.6.25 evaluate_0.14 glue_1.4.2 graphics_3.6.3 #' grDevices_3.6.3 highr_0.8 htmltools_0.5.0 jsonlite_1.7.1 knitr_1.30 #' magrittr_1.5 markdown_1.1 methods_3.6.3 mime_0.9 rlang_0.4.7 #' rmarkdown_2.3 rticles_0.16.1 stats_3.6.3 stringi_1.5.3 stringr_1.4.0 #' tinytex_0.26 tools_3.6.3 utils_3.6.3 xfun_0.17 yaml_2.2.1 ```By filing an issue to this repo, I promise that
xfun::session_info('rticles')
. 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/rticles')
.I understand that my issue may be closed if I don't fulfill my promises.