Overlay text on image in header of docx - rmarkdown - r

Using r markdown, I need to overlay a string on an existing image in the header of a docx one that is aligned to the bottom right hand corner of the header.
Also, I need to be able to alter the content of the string if possible.
I've got the image using the reference document approach suggested by Yihui Xie in the YAML header:
---
title: "Untitled"
author: "Simon"
date: "Thursday, May 21, 2015"
output:
word_document:
reference_docx: template_image.docx
---
[edit] In case it is helpful you can find template_image.docx here. If anyone could tell me how I could overlay text on that header image using rmarkdown I could appreciate it very much.

Related

Change size of a section of pandoc text for docx rendering

I'm trying to reduce the size of a section of text within a qmd document that needs rendering in docx.
I tried using a styled div:
---
title: "Test"
format: docx
---
The main text will be normal-sized.
::: {style="font-size: 10pt;"}
This block of text should be sized 10pt.
:::
Observed output:
Intended outptut:
Of note, my code works well in html.
Is there another way of doing this with a docx output?
The styling process for docx is a little different: one needs to create a "reference doc", set the styles in that doc and apply it with
---
format:
docx:
reference-doc: my-styled-reference.docx
---
See How to specify the font used for word doc exported using pandoc? and How do I add custom formatting to docx files generated in Pandoc? for more details on this process.

numbered table of content in md_document or github_document

I am having trouble with the table of content in a md_document or github_document.
If I do that, the TOC is displayed in the rendered document, but the links do not work:
---
output:
md_document:
toc: true
toc_depth: 4
---
### 1. Header
### 2. Header
#### 2.1. Subheader
#### 2.2 Subheader
Same problem with github_document; but no problem with html_document.
If I remove the numbers in the section headers, the links in the TOC work.
Is there a way to have section numbers in an md or github_document?
Unfortunately, GitHub does not display HTML docs nicely, so I have to use either md or github_document, but my file is long and the numbering would help to follow its structure.
Thank you in advance
What if you back "md_document:" up so it is directly under the "Output:"? You said your links work when you remove the numbers in the section headers, but I don't see any links?

Caption styles for word_document2 in bookdown

I've got an .Rmd I need to output using the word_document2 format with R bookdown. It has a .docx template which works fine for heading styles etc.
However, it appears that the figure/table captions are output using the "normal" style, so I can't control the font, size etc. on them as a group and am having to go through after the fact and change them all by hand. Is there a way to get bookdown to designate them to use Word's "caption" style, or alternatively to specify a custom style for them?
In your YAML header for your .Rmd, you can specify a Word doc to use as the basis for all formatting. Your rendered word doc will pick up all the styles from this reference_docx and apply them to your output:
---
title: "Example .Rmd"
output:
word_document:
toc: yes
reference_docx: word-styles-reference-01.docx
theme: hpstr
fontsize: 11pt
---
The Word file that I am using for styles is here: https://drive.google.com/open?id=1gSyE22hJbGdsTj6C-RWBTnyBVnG0XwB3
In trying to make a reproducible example, I found the problem (apologies for not including an example in the first place).
The issue wasn't with the .Rmd, but the reference .docx itself. It had a "Caption" style, but for some reason it didn't have "Image Caption" or "Table Caption" styles, which is what markdown was looking for. I copied those styles over from another Word document according to these instructions, and now it works fine.

Rmarkdown: is it possible to get a nice verbatim code in ioslides?

I am using Rmarkdown and ioslides.
I would like to get this nice text with gray background and monospace font that I can get on stackoverflow when one embeds text within ``
Unfortunately, when I use this syntax in my ioslides, my text appears more like verbatim code than verbatim code.
Text enclosed within `` renders correctly when the output is html, but does not seem to work with ioslides
Example
---
title: "Untitled"
output: ioslides_presentation
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## R Markdown
Here is the problem, fella: I want some nice `verbatim code`
gives
where is my nice background and my nice font?
Is there anything one can do here? Maybe playing with the css?
Thanks!

Text Justification in Rmarkdown word document

When I create the word document in Rmarkdown, text is always left-aligned:
Is it possible (and how) to justify the text in Rmarkdown?
A template (i.e., like a custom style sheet) can be created in Word (or LibreOffice / OpenOffice), containing whatever page formatting and document styles you wish, and referenced from the rmarkdown file, i.e.,
---
title: "My Document"
output:
word_document:
reference_docx: mystyles.docx
---
...rest of your rmarkdown here...
See:
https://vimeo.com/110804387
http://rmarkdown.rstudio.com/word_document_format.html
http://rmarkdown.rstudio.com/articles_docx.html

Resources