Comments (3)
It may be possible to build a TOC with 2 different styles (if it is, I will try to add the feature).
For now, if you want that kind of sequence, you need to go deeper in Word SEQ field. This makes things harder to write but still it is possible. I don't recommend this solution as it is not a standard and it makes the code more difficult to maintain.
# file index.Rmd
---
title: "officedown Example"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
documentclass: book
biblio-style: apalike
link-citations: yes
description: "This is a minimal example of using the officedown package to write a Word document."
---
```{r include=FALSE}
library(knitr)
library(officedown)
library(officer)
library(magrittr)
opts_chunk$set(echo = TRUE)
any_zz <- list(
run_word_field("STYLEREF 1 \\s"),
ftext("."),
run_autonum(seq_id = "fig", pre_label = "", post_label = "")
)
one_zz <- list(
run_word_field("STYLEREF 1 \\s"),
ftext("."),
run_autonum(seq_id = "fig", start_at = 1, pre_label = "", post_label = "")
)
```
```{r}
block_toc(level = 1)
```
```{r}
block_toc(style = "Image Caption")
```
# file 01-intro.Rmd
# Introduction {#intro}
```{r}
plot(iris[, 4:5])
```
::: {custom-style="Image Caption"}
图 `r run_bookmark("iris", any_zz)` plot of iris
:::
Reference of \@ref(fig:iris)
```{r}
plot(iris[, 1:2])
```
::: {custom-style="Image Caption"}
图 `r run_bookmark("iris2", any_zz)` plot of iris2
:::
Reference of \@ref(fig:iris2)
# file 02-plots.Rmd
# Chapter 2 {#c2}
```{r}
plot(iris[, 2:3])
```
::: {custom-style="Image Caption"}
图 `r run_bookmark("iris3", one_zz)` plot of iris3
:::
Reference of \@ref(fig:iris3)
It produces this:
The idea is to reproduce Word functionality (:/ difficult to maintain) Restart numbering. That is represented by the instruction \\r 1
. The sequence identifier is fig
.
from officedown.
Thanks for your reply. It works!
Unfortunatley, I know little about Word SEQ field. But now I get that \\r 1
means restart to number from 1. Thus, for each chapter, what I need is to run_bookmark
for the first figure based on one_zz
and run other bookmarks based on any_zz
. And the TOC could finally be generated by block_toc(seq_id = "fig")
.
By this way, the stuff about different styles seems unnecessary. But I am also happy to see that new feature.
from officedown.
I added an argument start_at
in function run_autonum
(and update the example below)
from officedown.
Related Issues (20)
- 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
- Header Problems concomitant with page numbering 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
- landscape? HOT 1
- block_caption() in markdown corrups Word files HOT 5
- 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
- Images in page headers of reference docx misplaced when using <!---BLOCK_LANDSCAPE_START---> <!---BLOCK_LANDSCAPE_STOP---> HOT 2
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.