Search code examples
rknitrbookdown

How to configure twitter button in Bookdown?


I would like to know how to configure twitter button in bookdown's gitbook output format.

I couldn´t find the answer in Authoring Books and Technical Documents with R Markdown


Solution

  • From https://bookdown.org/yihui/bookdown/html.html#gitbook-style

    bookdown::gitbook:
        config:
            sharing:
            facebook: yes
            twitter: yes
            google: no
            weibo: no
            instapper: no
            vk: no
            all: ['facebook', 'google', 'twitter', 'weibo', 'instapaper']
    

    On the right of the toolbar, there are some buttons to share the link on social network websites such as Twitter, Facebook, and Google+. You can use the sharing option to decide which buttons to enable. If you want to get rid of these buttons entirely, use sharing: null (or no).

    Here is a minimal example:

    index.Rmd

    ---
    title: "A Book"
    author: "Frida Gomam"
    site: bookdown::bookdown_site
    output:
      bookdown::gitbook: 
        config: 
          sharing:
            twitter: yes
    ---
    
    # reference
    
    This is my table \@ref(tab:mytable)
    
    # table
    
    ```{r mytable, echo=TRUE}
    knitr::kable(iris[1:10, ], booktabs=T, caption='A table of the first 10 rows of the mtcars data')
    ```
    

    enter image description here enter image description here