rlatexr-markdownbeamer

Change color of numbered list


Using Beamer in R Markdown (in R Studio, Windows 10), I am trying to change the color of a numbered list (enumerate) to have a custom color. I was successful in doing so for bullet points (itemize).

This post covers the process for itemize, but I can't get it to work for enumerate.

I would prefer to keep using the theme and colortheme if possible.

MRE

---
title: "test"
author: "author"
date: "date"
output: 
  beamer_presentation:
    theme: Berlin
    colortheme: beaver
    keep_tex: true
header-includes:
  - \usepackage{xcolor}
  - \definecolor{berlinred}{rgb}{0.64,0,0}
  - \setbeamercolor{itemize item}{fg=berlinred}
  - \setbeamercolor{itemize subitem}{fg=berlinred}
  - \setbeamercolor{enumerate item}{fg=berlinred}
  - \setbeamercolor{enumerate subitem}{fg=berlinred}
  - \setbeamercolor{enumerate subsubitem}{fg=berlinred}
---

## Slide with Bullets

- Bullet 1
- Bullet 2
- Bullet 3

## Slide with Numbered List

1. hi
2. hello
3. greetings

Current Output

default color for numbered list

Desired Output

Similar to current output, but instead of a blue square surrounding the numbers, use the color defined by \definecolor{berlinered}{rgb}{0.64,0,0} in the YAML section above.

Software Versions

I'm guessing the versions are not the problem, but I'm including them for completeness.


Solution

  • You can change the item projected colour:

    ---
    title: "test"
    author: "author"
    date: "date"
    output: 
      beamer_presentation:
        theme: Berlin
        colortheme: beaver
        keep_tex: true
    header-includes:
      - \definecolor{berlinred}{rgb}{0.64,0,0}
      - \setbeamercolor{itemize item}{fg=berlinred}
      - \setbeamercolor{itemize subitem}{fg=berlinred}
      - \setbeamercolor{enumerate item}{fg=berlinred}
      - \setbeamercolor{enumerate subitem}{fg=berlinred}
      - \setbeamercolor{enumerate subsubitem}{fg=berlinred}
      - \setbeamercolor{item projected}{bg=berlinred}
    ---
    
    ## Slide with Bullets
    
    - Bullet 1
    - Bullet 2
    - Bullet 3
    
    ## Slide with Numbered List
    
    1. hi
    2. hello
    3. greetings
    

    enter image description here