Search code examples
rofficer

Multiple text formats in unordered list


I'm trying to bold a single word within a sentence in an unordered list bullet (in PPT). Is this possible? Putting a combination of fpar/ftext objects into the str_list within unordered_list throws an error. Thanks in advance.

EDIT, adding example of what I mean:

example


Solution

  • I have the same issue. My colleague gave me this chunk of code:

    pres_1 <- read_pptx(path = template) %>%
        add_slide(layout = 'Title and Content', master = 'Office Theme') %>%
        ph_empty(type = 'body') %>%
        ph_add_par() %>%
        ph_add_text(str = 'this is a red text', style =  fp_text(color = 'red', font.size = 20)) %>%
        ph_add_text(str = ' followed by a blue text', style = fp_text(color = 'blue', font.size = 20)) %>%
        ph_add_par(level = 2) %>%
        ph_add_text(str = 'Level 2', style = shortcuts$fp_italic() ) %>%
        ph_add_par(level = 3) %>%
        ph_add_text(str = 'Level 3', style = shortcuts$fp_bold())
    
      print(pres_1, "test.pptx")
    

    It still works with officer 0.3.5 but it is not documented any more on the documentation page of the current package version (https://davidgohel.github.io/officer/index.html).

    I wonder what would be the intended way to implement this using the function documentation from the above site.