How do you suppress captions for a texreg table? I'm using Rmarkdown to generate a LaTeX file. Here's a simple example:
```{r, echo=FALSE, message=FALSE, results="asis"}
library(texreg)
data <- data.frame(a=c(1,2,3,4), b=c(6,3,4,4))
texreg(lm(a~b, data=data), caption="", custom.note="", float.pos="h!")
```
The table I get has a caption on the bottom that says "Table 1:". How do I get rid of it? Thanks.
In the YAML section where LaTeX packages can be included, add the caption package:
header-includes:
- \usepackage{caption}
Then at the beginning of the RMarkdown document body add:
\captionsetup[table]{labelformat=empty}
This removes the caption labels for all tables.
In case you have an external .tex file for additional formatting (i. e. I made a file for including a logo in the header of each page as described here) you should include \usepackage{caption} (just this line) in the external .tex file, not in the yaml header of the RMarkdown document.
Related
I'm currently writing in R Studio an R Markdown document. Since I am not using English, I want to change the name of the # References header to "Referencias". My output is HTML.
I went thru the pandoc documentation and tried reference-section-title: Referencias in my YALM header, with no luck.
The easiest way is to set the metadata field reference-section-title in the YAML header:
---
reference-section-title: Referencias
---
Alternatively, you could write the section title directly into the document, then use a special fenced div with id #refs to place the bibliography anywhere you need it:
# Referencias
::: #refs
:::
I want to have a dynamic header to appear on every page of word document after knitting an r markdown file. The header includes the document title and ID that are the user inputs passed to r markdown via r shiny app.
I followed the link https://vimeo.com/110804387 to create header for word template Template.docx. The header appears on every page but the parameters from YAML can't be passed to the header.
The header in the Template.docx:
Document title: `r params$title`
Document ID: `r params$id`
The YAML in r markdown:
output:
word_document:
reference_docx: Template.docx
params:
title: title
id: id
The word template image:
Image of the Template.docx
Do you know how I can get the parameters passed to the header? I really appreciate your help. I'm learning R and working on this first project at the same time. I'm using RStudio.
try adding quotes to `r ` --> "`r `"
I have a summary figure that I want to insert at the top of my HTML report generated using knitr/rmarkdown. But the inputs of this figure depend on outputs generated from downstream code chunks and child documents. Is there a way to do this without having to put the summary figure at the end of the document?
I have tried ref.label='last' option in the top level code chunk (with eval=FALSE) to add a duplicate code chunk in the end of the document {r last, eval=TRUE}, but has not worked for me.
Any suggestions?
You can insert HTML anywhere into your document referencing the figure by the name knitr will use for it.
To figure out the name, temporarily change the YAML header to something like this:
output:
html_document:
self_contained: FALSE
This won't embed figures in the output, they'll be kept in a separate directory. Open the output in an editor, or view source in a browser, and look for the line that displays the figure. In my test example below, it was being displayed by this code:
<p><img src="Untitled2_files/figure-html/rnormplot-1.png" width="672" /></p>
I copied that line into the document, and removed the self_contained setting, and got this source code:
---
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
This is the figure before it was generated:
<p><img src="Untitled2_files/figure-html/rnormplot-1.png" width="672" /></p>
And here it is being generated:
```{r rnormplot}
x <- rnorm(100)
plot(x)
```
One key is to name the code chunk that generates the plot (mine is named rnormplot) because that helps to make sure the figure name is independent of the rest of the document.
I try to get Highouts Output in my Powerpoint presentation, but the suggestion does not work .This feature is still pretty new and I was not able to find something valueable in the docu.
---
title: "Untitled"
output:
beamer_presentation: default
powerpoint_presentation: default
ioslides_presentation: default
always_allow_html: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(highcharter)
```
### R Markdown
This is an R Markdown presentation. 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.
### Slide with Bullets
- Bullet 1
- Bullet 2
- Bullet 3
### Slide with R Output
```{r cars, echo = TRUE}
highchart() %>%
hc_add_series(data = mtcars, type = "bar", hcaes(y = cyl))
```
### Slide with Plot
```{r pressure}
plot(pressure)
```
Produces:
Functions that produce HTML output found in document targeting pptx output.
Please change the output type of this document to HTML. Alternatively, you can allow
HTML output in non-HTML formats by adding this option to the YAML front-matter of
your rmarkdown file:
always_allow_html: yes
Note however that the HTML output will not be visible in non-HTML formats.
I added the always_allow_html: yes part to the top, but it still does not work. Can anyone help me?
I'm writing a document in R Markdown and I'd like it to include a footer on every page when I knit a PDF document. Does anyone have any idea on how to do this?
Yes, this question has been asked and answered here: Adding headers and footers using Pandoc. You just need to sneak a little LaTeX into the YAML header of your markdown document.
This markdown header does the trick:
---
title: "Test"
author: "Author Name"
header-includes:
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \fancyhead[CO,CE]{This is fancy header}
- \fancyfoot[CO,CE]{And this is a fancy footer}
- \fancyfoot[LE,RO]{\thepage}
output: pdf_document
---
Works for me with an Rmd file in RStudio Version 0.98.1030 for Windows.
Another option would be to use the argument includes provided by rmarkdown::pdf_document() (documentation). This allows you to keep the footer in a separate file. If your footer is defined in footer.tex, the header of your R Markdown file would look like this:
---
output:
pdf_document:
includes:
after_body: footer.tex
---
This also assumes that footer.tex is in the same directory as the R Markdown file.
Update: The file footer.tex can contain any valid LaTeX that you want to be inserted at the end of your PDF document. For example, footer.tex could contain the following:
This \textbf{text} will appear at the end of the document.
To manage the height of the footer, you can use the following:
date: '`r paste("Date:",Sys.Date())`'
output:
pdf_document:
latex_engine: xelatex
header-includes:
- \setlength{\footskip}{-50pt} # set the footer size
Keep Coding!