body_add_caption: add Word caption

Description Usage Arguments See Also Examples

View source: R/docx_add.R

Description

add a Word caption into an rdocx object.

Usage

1
body_add_caption(x, value, pos = "after")

Arguments

x

an rdocx object

value

an object returned by block_caption()

pos

where to add the new element relative to the cursor, one of "after", "before", "on".

See Also

Other functions for adding content: body_add_blocks(), body_add_break(), body_add_docx(), body_add_fpar(), body_add_gg(), body_add_img(), body_add_par(), body_add_plot(), body_add_table(), body_add_toc()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
doc <- read_docx()

if( capabilities(what = "png") )
  doc <- body_add_plot(doc,
    value = plot_instr(
      code = {barplot(1:5, col = 2:6)}),
      style = "centered" )
run_num <- run_autonum(seq_id = "fig", pre_label = "Figure ",
  bkm = "barplot")
caption <- block_caption("a barplot", style = "Normal",
  autonum = run_num )
doc <- body_add_caption(doc, caption)
print(doc, target = tempfile(fileext = ".docx") )

Example output



officer documentation built on July 21, 2021, 5:07 p.m.