addTOC-methods: Insert a table of contents into the docx document

Description Usage Arguments Details Examples

Description

Insert a table of contents into the Docx object.

Usage

1
2
  ## S4 method for signature 'Docx,character'
addTOC(x, stylename)

Arguments

x

the Docx to use

stylename

name of the style used to construct the TOC

Details

This function add a table of contents in a doc object.
It can also add custom table of contents, for example a table of content for the added plots.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# example 1
doc <- new("Docx", title = "My example" )
doc <- addTOC(doc)
# add headers and content here
writeDoc( doc, "toc_example.docx" )




# example 2
require(ggplot2)
doc <- new("Docx", title = "My example" )
# Because we will use "PlotReference" as legend in plot 
# later, addTOC will use this stylename to define 
# entries in the generated TOC 
doc <- addTOC(doc, stylename = "PlotReference")

doc = addPlot( doc
		, fun = plot
		, x = rnorm( 100 )
		, y = rnorm (100 )
		, main = "base plot main title"
		, legend="graph example 1", stylename = "PlotReference"
	)

doc = addTable( doc, iris )
doc = addParagraph( doc, value="table 1", stylename = "PlotReference" )

doc = addPlot( doc
		, fun = plot
		, x = rnorm( 100 )
		, y = rnorm (100 )
		, main = "base plot main title"
		, legend="graph example 2", stylename = "PlotReference"
	)


writeDoc( doc, "toc_example.docx" )

davidgohel/R2DOCX documentation built on May 14, 2019, 11:13 p.m.