I am writing rmarkdown and am exporting to odt and to html. I can get a TOC in the generated html and I can get a TOC in the generated odt, but I cannot get a TOC in both simultaneously, as the code seems mutually exclusive.
How can I have a TOC generated from the same Rmd file in both, odt and html?
Here is how I get the TOC in odt:
---
title: Test TOC
toc: yes
toc-title: TOC
output:
odt_document:
keep_md: true
html_document:
number_sections: true
---
# Just a test document
With some text
Here is how I get the TOC in html:
---
title: Test TOC
output:
odt_document:
keep_md: true
html_document:
toc: yes
toc-title: TOC
number_sections: true
---
# Just a test document
With some text
If I combine the two, I get 'yes' as TOC in html.
I am using rmarkdown 1.12 and pandoc-2.7.3
Posting a work-around here. But I am still interested in a better answer.
As a work-around I have renamed toc as odt-toc and toc-title as odt-toc-title in the odt template.
In more detail I use this Rmd file:
---
title: Test TOC
odt-toc: yes
odt-toc-title: TOC
output:
odt_document:
keep_md: true
html_document:
toc: yes
toc-title: TOC
number_sections: true
---
# Just a test document
With some text
with a modified version of the default odt-template where I have replaced
$if(toc)$
by
$if(odt-toc)$
and
<text:index-title-template text:style-name="Contents_20_Heading">$toc-title$</text:index-title-template>
by
<text:index-title-template text:style-name="Contents_20_Heading">$odt-toc-title$</text:index-title-template>
Related
I am trying to make Beamer presentation in R Markdown, you can see how code begin below :
---
title: "Test presentation"
author:
- Loana
institute:
- Supervised by
- University
date: Academic year 2017-2018
output:
beamer_presentation:
incremental: false
theme: "Frankfurt"
colortheme: "beaver"
toc: true
slide_level: 5
keep_tex: true
header-includes:
- \AtBeginSubsection{}
---
This code give output like pic below
But my intention is to have navigation bar in right corner of slide, so can anybody help me how to do this ?
Is the following your desired output?
If so, create a file header.tex with the following contents (taken from https://tex.stackexchange.com/a/35637/181010)
\setbeamertemplate{navigation symbols}{}
\makeatletter
\setbeamertemplate{footline}
{%
\pgfuseshading{beamer#barshade}%
\ifbeamer#sb#subsection%
\vskip-9.75ex%
\else%
\vskip-7ex%
\fi%
\begin{beamercolorbox}[ignorebg,ht=2.25ex,dp=3.75ex]{section in head/foot}
\insertnavigation{\paperwidth}
\end{beamercolorbox}%
\ifbeamer#sb#subsection%
\begin{beamercolorbox}[ignorebg,ht=2.125ex,dp=1.125ex,%
leftskip=.3cm,rightskip=.3cm plus1fil]{subsection in head/foot}
\usebeamerfont{subsection in head/foot}\insertsubsectionhead
\end{beamercolorbox}%
\fi%
}%
\setbeamertemplate{headline}{%
\hskip1em\usebeamercolor[fg]{navigation symbols dimmed}%
}
\makeatother
Then add the header to the yaml of your .Rmd as:
---
title: "Test presentation"
author:
- Loana
institute:
- Supervised by
- University
date: Academic year 2017-2018
output:
beamer_presentation:
incremental: false
theme: "Frankfurt"
colortheme: "beaver"
toc: true
slide_level: 5
keep_tex: true
header-includes:
- \AtBeginSubsection{}
- \input{header.tex}
---
I'd like to have the section titles in the header not the body of the page. \fancyhead[C]...puts the section title in the header but how do you suppress the body printing of the section?
---
title: "Untitled"
classoption: landscape
output:
pdf_document:
number_sections: false
dev: pdf
keep_tex: false
toc: yes
header-includes:
- \usepackage{fancyhdr}
- \usepackage{etoolbox}
- \pagestyle{fancy}
- \fancyhead[L]{left}
- \fancyhead[R]{right}
- \fancyhead[C]{ \nouppercase{\leftmark} }
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r cars}
summary(cars)
```
\newpage
# Including Plots
You can also embed plots, for example:
```{r pressure, echo=FALSE}
plot(pressure)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
\newpage
# page 3
You can also embed plots, for example:
```{r pressured, echo=FALSE}
plot(pressure)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
I am trying to build a book, with 9 chapters. I am using the bookdown::bookdown_site package for that, which I have included in the YAML header in index.Rmd. But when I knit the book, using bookdown::tufte_book2, the pdf file generate the text inside the chunks with different font colors.
When I try to run each chapter individually, using "tufte_handout", the outcome is as expected. Main text and inside chunk text is monochrome and TimesNewRoman.
In rStudio, before build the book, I have tried in Sweave/Program defaults to use both Latex Engines, "xeLaTex" and "pdfLaTex"
YAML header in index.Rmd
---
title: "Operations Research Using R<br />"
author: "Timothy R. Anderson"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
monofont: Times New Roman
highlight: monochrome
documentclass: book
bibliography: ["Master4Bookdowns.bib"]
---
YAML header in each individual ChapterX.Rmd file:
---
title: 'Chapter 3: More LP Models'
header-includes:
- \usepackage{longtable}
- \usepackage{caption}
monofont: Times New Roman
output:
tufte::tufte_handout:
citation_package: natbib
latex_engine: xelatex
toc: TRUE
number_sections: true
highlight: monochrome
tufte::tufte_html: default
tufte::tufte_book:
citation_package: natbib
latex_engine: xelatex
highlight: monochrome
---
I expect all document with the same font type and monochrome.
Since bookdown::tufte_book2 is not specified in your main YAML header, I assume you have an _output.yml file that defines the output format. In that case, you have to add highlicht: monochrome there, i.e.:
bookdown::tufte_book2:
highlight: monochrome
[other options]
So.
I want to insert some image files into an Rmarkdown document, auto-generate labels and be able to reference those images from elsewhere in the text. I'm using bookdown, so I start off with
---
output:
html_document:
toc: true
number_sections: true
fig_caption: true
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(bookdown)
```
According to the bookdown manual if I have the following code chunk:
```{r knnPlot, echo=FALSE, fig.cap="Knn Plot"}
knitr::include_graphics("knn-cs3-gs2.png")
```
then I should have a label fig:knnPlot automatically generated, because using fig.cap apparently puts R in a figure environment and automatically prepend "fig" to the label. It then tells me I should be able to reference the figure using \#ref(label), or rather, in this case, \#ref(fig:knnPlot)
When I do this however, the text "\#ref(fig:knnPlot)" is output, rather than an actual cross reference. There's no figure label, no numbering. How is this meant to work?
I can't get the hard coding method suggested here to work. Nor can I get the only other option I can find to work, it tells me to install pandoc-crossreference, which leads me down an absurd rabbit hole of installing haskell of all things along with endless dependencies and obscure pointless error messages which lead to spectacularly unhelpful developer forums filled with 6 pages of error logs.
You are not creating a bookdown document. Use bookdown::html_document2 instead:
---
title: "Bookdown"
output:
bookdown::html_document2:
fig_caption: yes
number_sections: yes
toc: yes
---
```{r Doge, echo=FALSE, fig.cap="Mighty Doge"}
knitr::include_graphics("unnamed.png")
```
Check out this picture: \#ref(fig:Doge)
I am trying to create a report in R markdown that has sections ordered
Section 1 Header
1.1 sub section 1
1.2 sub section 3
Section 2 Header
2.1
2.2 sub section
2.2.1 another sub section
Is there a way get R markdown to generate an ordered list like this?
Add the option number_sections: true to your YAML header:
---
title: "My Report"
output:
html_document:
number_sections: true
---
# Main Section
## 2nd Level
### 3rd Level
And voilá, your sections are numbered: