Set manually headers'styles of a docx object
# S3 method for docx
declareTitlesStyles(doc, stylenames, ...)
docx
object to be used with declareTitlesStyles.
existing styles (character vector) where first element represents the style to use for title 1, second element represents the style to use for title 2, etc.
further arguments, not used.
Function addTitle
need to know which styles
are corresponding to which title level (1 ; 1.1 ; 1.1.1 ; etc.).
When template is read, function docx
try to guess what
are theses styles. If he do not succeed, an error occured saying
'You must defined header styles via declareTitlesStyles first.'. In that
case, run styles(...)
to see what are available styles, then
declareTitlesStyles to indicate which available styles are meant to be
used as header styles.
# NOT RUN {
#START_TAG_TEST
doc.filename = "addImage_example.docx"
# set default font size to 10
options( "ReporteRs-fontsize" = 10 )
doc = docx( )
styles( doc )
# [1] "Normal" "Title1" "Title2"
# [4] "Title3" "Title4" "Title5"
# [7] "Title6" "Title7" "Title8"
#[10] "Title9" "Defaut" ...
doc = declareTitlesStyles(doc
, stylenames = c("Titre1", "Titre2", "Titre3"
, "Titre4", "Titre5", "Titre6", "Titre7", "Titre8", "Titre9" ) )
doc = addTitle( doc, "title 1", 1 )
#STOP_TAG_TEST
# }
Run the code above in your browser using DataLab