I am trying to add a subscript to a caption generated in officer. I am creating the caption like this:
library(officer)
doc <- read_docx('empty_file.docx')
autonum <- run_autonum(seq_id = 'fig', pre_label = 'Figure ')
caption <- block_caption(label='My caption includes SO2.', style = "caption", autonum = autonum)
doc <- body_add_caption(doc, caption)
print(doc, target = 'output.docx'))
However, now I'd like to put the '2' in 'SO2' in subscript. I know how to generate subscripts:
fp_text_prop <- fp_text(color='orange')
prop_mod <- update(fp_text_prop, vertical.align = 'subscript')
paragraph <- fpar(ftext('SO', prop = fp_text_prop), ftext('2', prop = prop_mod)))
But I can't use the resulting fpar
inside a caption, as body_add_caption
expects the output from block_caption
and block_caption
expects a normal string as argument for the label=
.
How can I put an fpar
, or alternatively, a subscript inside a caption?