Skip to content

Add odt_document2 and powerpoint_presentation2#742

Merged
yihui merged 9 commits intorstudio:masterfrom
atusy:feat/add-outputs
Aug 9, 2019
Merged

Add odt_document2 and powerpoint_presentation2#742
yihui merged 9 commits intorstudio:masterfrom
atusy:feat/add-outputs

Conversation

@atusy
Copy link
Collaborator

@atusy atusy commented Jul 14, 2019

This PR adds odt_document2 and powerpoint_presentation2 and closes #722 #741
Though I'm not sure powerpoint_presentation2 is a scope of bookdown, bookdown is the only place to implement it.

odt

I rendered inst/examples/index.Rmd.
The result seems to be fine.

bookdown.zip

Exceptionally, when math expressions appeear right after the code blocks, the math expressions appear within code blocks.
However, this is not a problem of bookdown because the same problem occurs in rmarkdown::odt_document.

image

pptx

Cross reference seems to be working fine

image

---
output: bookdown::powerpoint_presentation2
---

# Cross-reference

```{r iris, fig.cap="iris"}
plot(iris)
```

`\@ref(fig:iris)` becomes \@ref(fig:iris)

@atusy
Copy link
Collaborator Author

atusy commented Jul 24, 2019

May be it's better to factor out duplicated codes into a new function (office_document2_base?) from word_document2, powerpoint_presentation2, and odt_document2?

@yihui
Copy link
Collaborator

yihui commented Jul 24, 2019

Yes, that is exactly what I was thinking. Please do factor out the code instead of repeating it in three functions. Thank you!

@atusy
Copy link
Collaborator Author

atusy commented Jul 24, 2019

Done it by implementing office_document2_base.
It is not exported currently, but might be useful for users in case they want some formats to be transformed to bookdown's format.

As rewriting extremely simplfied odt.R and powerpoint.R, I integrated them into word.R.
Maybe we should renaming word.R to office.R or somethingl like that.

@atusy
Copy link
Collaborator Author

atusy commented Jul 29, 2019

I confirmed markdown_document2 well works with other formats (e.g., prettydoc::html_pretty.
Note that hyperlinks to referred tables and others are not working.

---
output: 
  bookdown::markdown_document2:
    base_format: prettydoc::html_pretty
---

# Table \@ref(tab:iris)

```{r iris}
knitr::kable(head(iris), caption = "iris")
```

# Table \@ref(tab:mtcars)

```{r mtcars}
knitr::kable(head(mtcars), caption = "mtcars")
```

Copy link
Collaborator

@yihui yihui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect. Thank you so much!

@yihui yihui added this to the v0.13 milestone Aug 9, 2019
@yihui yihui merged commit ea09a1a into rstudio:master Aug 9, 2019
yihui added a commit that referenced this pull request Aug 27, 2019
@jooyoungseo
Copy link

I confirmed markdown_document2 well works with other formats (e.g., prettydoc::html_pretty.
Note that hyperlinks to referred tables and others are not working.

---
output: 
  bookdown::markdown_document2:
    base_format: prettydoc::html_pretty
---

# Table \@ref(tab:iris)

```{r iris}
knitr::kable(head(iris), caption = "iris")

Table @ref(tab:mtcars)

knitr::kable(head(mtcars), caption = "mtcars")

@atusy, bookdown::markdown_document2 does not seem to work with redoc package.

Cross-references are broken in the rendered results. Would you mind testing it with the following?:

---
output: 
  bookdown::markdown_document2:
    base_format: redoc::redoc
---

Table \@ref(tab:iris)

```{r iris}
knitr::kable(head(iris), caption = "iris")
```

Table \@ref(tab:mtcars)

```{r mtcars}
knitr::kable(head(mtcars), caption = "mtcars")
```

Figure \@ref(fig:histogram)

```{r histogram}
hist(airquality$Ozone, col="blue")
```

@atusy
Copy link
Collaborator Author

atusy commented Sep 21, 2019

As far as I tried, broken cross-references occur only at Table \@ref(tab:iris).
If keep_md: true is specified, you see the line is converted to

Table \<span class="redoc" id="redoc-citation-1"><span class="redoc" id="redoc-citation-2"><span class="redoc" id="redoc-citation-3">@ref</span></span></span>(tab:iris)

I think this is the reason and is caused by redoc package.
Maybe @noamross knows what is happening.

Besides, Figure \@ref(fig:histogram) is converted to Figure ?? in docx.
This is because you did not specify fig.cap for the histogram chunk.

BTW, I recommend opening issue when you see strange behavior instead of making comments on closed PR.
Then, more people notices the issue and possibly solve it more quickly.
(This is just my opinion)

@noamross
Copy link
Contributor

noamross commented Sep 22, 2019

This is most likely caused by the redoc package as I haven't yet done the work to make sure its post-processing is compatible with these formats. Feel free to open an issue over there.

matthew-brett added a commit to matthew-brett/bookdown-demo that referenced this pull request Nov 27, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

it would be great to support OpenDocument (odt) file format for output

4 participants