davidgohel / officedown

https://ardata-fr.github.io/officeverse/officedown-for-word.html
Other
366 stars 27 forks source link

rpptx always uses "Title and Content" layout #32

Closed Pindar777 closed 4 years ago

Pindar777 commented 4 years ago

Hi,

I just tried the sample rpptx and noticed that the "Two Columns" layout is not applied for generating the output-pptx-file. Neither for a chunk like in

{r layout='Two Content', ph=officer::ph_location_left()}

nor when changing the YAML.

I am working on Windows 10.

Cheers

davidgohel commented 4 years ago

I can't reproduce.

---
date: "`r Sys.Date()`"
author: "Your Name"
title: "Untitled"
output: 
  officedown::rpptx_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, fig.cap = TRUE)
library(officedown)
library(ggplot2)
library(rvg)

Table

head(cars)
head(iris)


<img width="1099" alt="Capture d’écran 2020-07-06 à 15 07 19" src="https://user-images.githubusercontent.com/4331618/86596393-6e065900-bf9a-11ea-8f16-454968e7ca2e.png">

Can you describe your issue so that we can help? Please provide a reproducible example, also provide your `sessionInfo()` results after loading `officedown` 
Pindar777 commented 4 years ago

Dear @davidgohel, thank you for the code snippet and the screenshot. That is exactly as it looks like on my machine. However, the "two column" layout is artificial, since the real layout behind that slide is still "Title and Content".

I the meantime I tried this code snippet

`## Two Columns Slide

:::::: {.columns} ::: {.column width="50%"} Content of the left column.

here should be a table, but it is not

Spalte 1 Spalte 2
A 10
B 20

:::

::: {.column width="90%"} Content of the right column.

Column width is ignored ::: :::::: `

This new slide uses the "right" layout. However in pptx there is no table shown at all. Even inserting r-chunks is in vain (e.g. via flextbale)

What I intend to get from rmarkdown in pptx is the ability to write text as a table and change the column widths. But so far I did not find a solution for that. (your flextable-package does include a working width-argument for provided dataframes but the tables do not follow the intended style guide).

Can you change the default layout in the YAML?

Cheers

Pindar777 commented 4 years ago

Dear @davidgohel,

IMHO the best to get would be implementing the idea from rdocx also in rpptx:

## Word-like columns notation for PowerPoint

The following will be in a separated section with 2 columns:

<!---BLOCK_MULTICOL_START--->
Blah blah blah on column 1.

<!---CHUNK_COLUMNBREAK--->
Blah blah blah on column 2.

<!---BLOCK_MULTICOL_STOP{widths: [1,3], space: 0.2, sep: true}--->

Here the columns can be designed. However, I'm pretty sure that powerpoint behaves completely different than word...

davidgohel commented 4 years ago

That is exactly as it looks like on my machine. However, the "two column" layout is artificial, since the real layout behind that slide is still "Title and Content".

I don't understand what is your issue. This is an R Markdown extension, it uses pandoc. That's what pandoc is generating. Using layout='Two Content', ph=officer::ph_location_left() in chunk options is like "use properties defined in left placeholder of the layout two content".

I the meantime I tried this code snippet

Same with default R Markdown powerpoint_presentation, you can't mix different types in PowerPoint.


What I intend to get from rmarkdown in pptx is the ability to write text as a table and change the column widths.

I am not sure it helps, but you could try with ph_location to control the exact size.

the intended style guide

The default values can be changed, see help pages here: https://davidgohel.github.io/flextable/articles/format.html

Can you change the default layout in the YAML?

No


IMHO the best to get would be implementing the idea from rdocx also in rpptx:

No, it does not behave the same

Pindar777 commented 4 years ago

@davidgohel I see, the "layout" argument is used to mirror the characteristics of certain placeholders.

Please check and update your documentation https://davidgohel.github.io/officedown/reference/rpptx_document.html

I assumed this would be possible:

---
date: "`r Sys.Date()`"
author: "Your Name"
title: "Untitled"
output:
     officedown::rpptx_document:
        layout: "Two Content"
---

I'm gonna try the ph_location. Thanks for the fast response and discussion.

davidgohel commented 4 years ago

Sorry, I understood you wanted to change the default value of the layout in the current implementation. Then, as stated in the documentation, you can use layout to use another default value for layout (that will be used to get placeholder settings).

Pindar777 commented 4 years ago

@davidgohel Update:

In order to position r-chunk tables according to predefined pptx-placeholders I created a "just for pandoc"-slide called "Textchart_2h_B'". This works for simple tables like "head(iris)". However, up until now I did not figure out, how to position a flextable.

This has no effect on the flextable. Perhaps there is a solution with ph_with inside the chunk? But what to do with the "x" argument, since we are inside/generating an rpptx object.

ft1 <- flextable(head(iris))
arrW <- dim_pretty(ft1)
ft1 <- width(ft1, width = arrW$widths)
ft1
# has not effect

Btw, the layout-YAML-Parameter has no effect at all. Perhaps you could provide a screenshot of the pptx-file with layout "Two Conten" inside the YAML.

Cheers

davidgohel commented 4 years ago

Is that not a new issue(s)?

If yes, could you open a new issue, one for each case, provide a reproducible example, provide the results of sessionInfo()

davidgohel commented 4 years ago
Capture d’écran 2020-07-08 à 12 31 16
Pindar777 commented 4 years ago

@davidgohel Thank you very much. In terms of ph_location_left I just noticed that this special function always uses the existing layout in 'Two Content', which cannot be overwritten.

For my flextable-issue I open a new issue.

Cheers

davidgohel commented 4 years ago

II assume you did not read the documentation of ph_location_left. It says:

The function will return the location corresponding to a right bounding box. The function assume the layout 'Two Content' is existing.

If you don't have that layout, use ph_location_type or another one. I have just completed the documentation by adding

This is an helper function, if you don't have a layout named 'Two Content', use [ph_location_type()] and set arguments to your specific needs.