Wilcar
Wilcar

Reputation: 2513

Bookdown how to change the title styles based on titles names

I have a book with h2 titles that are always the same in my book chapters :

h1 : text mining
h2 : course h2 : tutorial

h1 : programming with R h2 : course h2 : tutorial

...

I want to change the title styles based on titles names :

for exemple : green text color for h2 "course" (and h3 h4, ...)

blue text color for h2 "tutorial" (and h3 h4, ...)

The body text will be unchanged

h1 : text mining
h2 : course (green style) h2 : tutorial (blue style)

h1 : programming with R h2 : course (green style) h2 : tutorial (blue style)

...

Upvotes: 1

Views: 88

Answers (1)

s.kuznetsov
s.kuznetsov

Reputation: 15223

You can use classes for h tags. Each class contains a specific color.

.red {
  color: red;
}

.yellow {
  color: yellow;
}

.green {
  color: green;
}

.blue {
  color: blue;
}
<h1 class="red">text mining</h1>
<h2 class="green">course (green style)<h2> 
<h2 class="blue">tutorial (blue style)<h2>

<h1 class="yellow">programming with R</h1> 
<h2 class="green">course (green style)</h2> 
<h2 class="blue">tutorial (blue style)</h2>

Upvotes: 1

Related Questions