After using convert_docx_to_rmd(), figure and table captions are part of the main text and cross references to them are just text and numbers, making it difficult to integrate these .Rmd files in reports: they are not automatically renumbered, these captions cannot be listed,... This function replaces the figure and table descriptions with true captions, and cross references to these figures and tables with dynamic references (that refer to the figure or table label).

add_captions(
  from,
  to,
  name_figure_from = "Figuur",
  name_table_from = "Tabel",
  name_figure_to = "Figuur",
  name_table_to = "Tabel"
)

Arguments

from

The .Rmd file to convert. Can be given as an absolute or relative path.

to

The filename to write the resulting .Rmd file. Can be given as an absolute or relative path.

name_figure_from

name that is given to figures in captions and cross references in the .Rmd provided in from (default is Figuur)

name_table_from

name that is given to tables in captions and cross references in the .Rmd provided in from (default is Tabel)

name_figure_to

name that should be given to figures in cross references in the output .Rmd (default is Figuur)

name_table_to

name that should be given to tables in cross references in the output .Rmd (default is Tabel)

Details

This function expects an input that is generated by convert_docx_to_rmd(), with

  • figure captions below the figure and starting with Figuur (or other name to be defined in variable name_figure), then a unique number and finally the description in one paragraph

  • table captions above the table and starting with Tabel (or other name to be defined in variable name_table), then a unique number and finally the description in one paragraph

  • figures consisting of one image, not 2 figures near each other

  • cross references having the same label as the figure or table they refer to, default Figuur or Tabel followed by the unique number written in exactly the same way

Please check carefully for mistakes after using this function

See also

Other convert: convert_docx_to_rmd()