Comments (6)
hello, I just had a trial. I can see the page numbers after the inserted section in the default document provided in the package (doc here: https://github.com/davidgohel/officedown/blob/master/inst/rmarkdown/templates/word/skeleton/skeleton.Rmd)
Can you provide a reproducible example? I think you may have inserted a section but not the default one, just a new one (before the default one as it is defined at the end of the doc)
from officedown.
thanks for the answer, Please confirm if you used the header code provided or similar.
from officedown.
I don't understand, sorry. I am asking if you can provide a reproducible example because I want to try to reproduce your issue. I can not confirm you anything until I am able to reproduce your issue :)
from officedown.
I would use a template where header is containing the page number:
---
output:
officedown::rdocx_document:
reference_docx: template.docx
---
```{r, echo = FALSE}
library(officer)
library(officedown)
```
```{r results='asis', echo = F}
for(i in 1:50) cat("string1", "\n\n", sep = "")
```
```{r, echo = F, results = "asis"}
knit_print_run(
run_pagebreak()
)
```
```{r results='asis', echo = F}
for(i in 1:50) cat("string2", "\n\n", sep = "")
```
If you need to add Word sections, you will have to define the header corresponding to each new section. It applies to previous content (until previous section).
---
output:
officedown::rdocx_document:
reference_docx: template.docx
---
```{r, echo = FALSE}
library(officer)
library(officedown)
srcfile <- file.path(R.home("doc"), "html", "logo.jpg" )
header_template <- function(txt) {
block_list(
fpar(ftext(txt),
external_img(src = srcfile,
width = 0.435, height = .175),
"this is page number ",
run_word_field(field = "PAGE \\* MERGEFORMAT"),
fp_p = fp_par(
line_spacing = 2,
text.align = "left")
)
)
}
sec_pr <- prop_section(
header_default = header_template("text"),
type = "continuous"
)
```
```{r results='asis', echo = F}
for(i in 1:50) cat("string1", "\n\n", sep = "")
```
```{r, echo = F}
block_section(sec_pr)
```
```{r, echo = F, results = "asis"}
knit_print_run(
run_pagebreak()
)
```
```{r results='asis', echo = F}
for(i in 1:50) cat("string2", "\n\n", sep = "")
```
The last example shows the default section is used after a new section have been added. If you want to manage all headers, add a last section at then end so that it will be the last content defined in the doc and the default section will not have to appear:
---
output:
officedown::rdocx_document:
reference_docx: template.docx
---
```{r, echo = FALSE}
library(officer)
library(officedown)
srcfile <- file.path(R.home("doc"), "html", "logo.jpg" )
header_template <- function(txt) {
block_list(
fpar(ftext(txt),
external_img(src = srcfile,
width = 0.435, height = .175),
"this is page number ",
run_word_field(field = "PAGE \\* MERGEFORMAT"),
fp_p = fp_par(
line_spacing = 2,
text.align = "left")
)
)
}
sec_pr <- prop_section(
header_default = header_template("text"),
type = "continuous"
)
```
```{r results='asis', echo = F}
for(i in 1:50) cat("string1", "\n\n", sep = "")
```
```{r, echo = F}
block_section(sec_pr)
```
```{r, echo = F, results = "asis"}
knit_print_run(
run_pagebreak()
)
```
```{r results='asis', echo = F}
for(i in 1:50) cat("string2", "\n\n", sep = "")
```
```{r, echo = F}
block_section(sec_pr)
```
from officedown.
@fernandoroa why did you cross posted?
from officedown.
Thanks for the answers, really helpful. Because after analysis it seems it is not a bug/issue, so I imagined stack was a more appropriate place to continue and you could close the non-bug.
from officedown.
Related Issues (20)
- Images in page headers of reference docx misplaced when using <!---BLOCK_LANDSCAPE_START---> <!---BLOCK_LANDSCAPE_STOP---> HOT 2
- Math font in rdocx_document HOT 1
- Add image to word doc header without using reference docx
- Error when using `knit_print_block` in loop HOT 6
- Support {.unlisted .unnumbered} to exclude headings from table of contents HOT 2
- table caption style in yaml not used HOT 4
- insert section with page_margins, header and footer
- How to split long flextable in officedown powerpoint rmarkdown HOT 1
- block_caption() in markdown corrups Word files HOT 5
- landscape? HOT 1
- In-consistencies with the officeverse bookdown HOT 1
- layout='Content with Caption' not working HOT 2
- Header and footer from reference_docx not working with orientation switches.
- Knitting to word with hyperlink in footnote HOT 1
- Two column layout results in missing header and footer also affects Title and ToC.
- Applying a table style to a reference docx HOT 1
- Typo Readme HOT 2
- Non-reproducible code from the package example HOT 5
- Embedded fonts in reference document not carrying thru to output HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from officedown.