4

My problem is very similar to this question - originally I wanted to just separate the table of contents from the title page with R markdown.
I used the latex workaround proposed there to achieve this, but when i add a table of contents to R markdown and knit it as .pdf the table of contents has a bright pink coloured font. All the help I found so far was using something like
<span style="color:green">WORD_WITH_DIFF_COLOUR</span>
or
<font color='green'>WORD_WITH_DIFF_COLOUR</font>
to change the colour of some words, but it doesnt work when do something like
<font color='green'>'\tableofcontents</font>

I guess there is a way to change this, but I wasn't able to find anything till now...
Any help would be appreciated!

EDIT!
Using @Tad Dallas's tip i was able to get this far TOC halfway through

Community
  • 1
  • 1
davidski
  • 561
  • 1
  • 4
  • 16
  • 3
    You should be able to incorporate `LaTex` code either through the `yaml` using in_header [discussed here](http://rmarkdown.rstudio.com/pdf_document_format.html) or in the document by using something like this `\renewcommand{\cfttoctitlefont}{\color{RoyalBlue}}()`. This assumes you're using package `tocloft`, I believe. – Tad Dallas Dec 29 '15 at 17:04
  • Hey Tad thanks for the tip. This does change the colour of the toc font, but unfortunately it does it only for the word "Contents" while it leaves the rest the same :) – davidski Dec 30 '15 at 08:25
  • 1
    My apologies. `\renewcommand{\cftXfont}{\color{RoyalBlue}}()` should change the color of the entries themselves. – Tad Dallas Dec 30 '15 at 15:23
  • I had a look at the `tocloft` docs and tried exactly the same - you probably oversaw that the `X` in the command is just a place holder for chapter, section etc. Still no success though...thanks anyway! I guess I will switch to latex afterall. – davidski Dec 30 '15 at 15:39

2 Answers2

3

See the LaTeX Options section of the R Markdown documentation

All you have to do is add linkcolor: 'black' to the YAML.

mrp
  • 689
  • 2
  • 11
  • 28
0

In an attempt to apply @mrp's solution, it seems like the current solution is to add toccolor: 'blue'.

Found it in the Pandoc manual, as suggested in the R Markdown documentation.

pollytatouin
  • 81
  • 1
  • 6