Description Usage Arguments Details Examples
Insert a table of contents into the Docx
object.
1 2 | ## S4 method for signature 'Docx,character'
addTOC(x, stylename)
|
x |
the |
stylename |
name of the style used to construct the TOC |
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.
stylename
: Stylename in the document that will
be used to build entries of the TOC (a character vector of length 1).
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" )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.