0

I am trying to get the font in my Rmarkdown document to match that of the rest of my report. Essentially this creates the legend for my maps. The entire report is Rockwell, but I can not figure out how to change the font in the output of the pandoc.table. Below is my attempt by used panderOptions but it doesn't work.

---
tables: true
geometry: margin=1.0in
header-includes:
- \usepackage{lscape}
- \newcommand{\blandscape}{\begin{landscape}}
- \newcommand{\elandscape}{\end{landscape}}
- \newcommand{\bminione}{\begin{minipage}{0.75 \textwidth}}
- \newcommand{\bminitwo}{\begin{minipage}{0.25 \textwidth}}
- \newcommand{\emini}{\end{minipage}}
fig_caption: yes
mainfont: Rockwell
sansfont: Rockwell
---
\pagenumbering{gobble}
 **`r paste(i)` Projects Legend**
```{r pdf,echo=FALSE,warning=FALSE,error=FALSE,results='asis'}
library(pander)

#Isolate Waterbody in loop
WaterBody <- Datasubset[Datasubset$SWIM.Waterbody == i,]

#Restoration Projects Only
WQProjects <- WaterBody

#Create column that corresponds to map shapefiles
WQProjects$rowname <- 1:nrow(WQProjects)

#Drop all columns except for the ones you want to print 
WQProjects <- WQProjects[,c("rowname","Name","Status")]

#Name for columns
colnames(WQProjects) <- c("Map Number","Project Name", "Status")

#Numbers for rows
rownames(WQProjects) <- WQProjects$rowname

#Table format
panderOptions('graph.fontfamily','Rockwell')
panderOptions('graph.fontcolor','red')
pandoc.table(t = WQProjects,
             split.tables = Inf,
             split.cells = c(5,100,30),
             justify = "left",
             style = "multiline"
             )
```

Test font

Thank you everyone for your help.

Tj Laroue
  • 23
  • 7
  • `graph.fontfamily` and `graph.fontcolor` is applied only on plots (when used in `evals` or `Pandoc.brew`), but not on tables generated by `pandoc.table` (as there's no such markup in markdown). – daroczig Oct 25 '17 at 14:05
  • Right, that was just my last attempt before posting this question. Do you know how to change it on pandoc.table? – Tj Laroue Oct 25 '17 at 18:56
  • You cannot really do that with `pandoc.table`, as this function transforms the R object into R markdown, and there are no colors or font family in markdown -- that's plain text. You can change the style of the text (eg body, tables, captions etc) by using stylesheets -- depending on your output format. So here you need some LaTeX magic to update the font family in the document and all tables – daroczig Oct 25 '17 at 19:46
  • Darn, I was afraid of that. I will try a different package or style of table, do you have a recommendation so that I could change the font? Thanks in advance! – Tj Laroue Oct 26 '17 at 12:42
  • If you want to tweak font family and color of a table overall, then there's no need to use another package -- you just have to apply a stylesheet on the document. But if you want to change color etc on the cell level, you have to generate LaTeX tables, look at eg `xtable` – daroczig Oct 26 '17 at 15:02
  • How would I go about applying a styleshet on a document? I have never heard of this for a PDF document. – Tj Laroue Nov 01 '17 at 17:25
  • Search for LaTeX preamble – daroczig Nov 02 '17 at 00:07

0 Answers0