Table moving to the next page in Rmarkdown-word - r

I would like my text to come immediately after my text in Rmarkdown. How do go about this? Currently, my results tables start on a new page instead of after the text when I knit to a word document.

Related

How to underline a link in R markdown?

I am creating a r markdown script to create a word document and I am pulling need to include a series of hyperlinks. However the links end up looking very similar to Word headings and I've been told to underline them to help distinguish.
my current code is something like this:
[dat$title](dat$link)
and I've tried
[dat$title](dat$link){.underline} and [dat$title]{.underline}(dat$link)
but the first doesn't work and the second ends up printing the url alongside the title.
You can wrap the link inside a <span>-element and specify the style-attribute like so:
<span style="text-decoration:underline"> [title](link) </span>.

Add a separate table of content in a HTML bookdown output

I created a website using bookdown package and I have a nice table of content on the left, which is fine.
But now I would like to add the same table of content in a separate chapter (while keeping the toc on the left). I am looking to something somehow similar to what I can do in Latex when using \tableofcontent and be able to put the table of content whenever I want in any section. Is there a simple way to do so, without having to manually copy paste content from the html output?
Maybe I am not using the right keywords but I can't find any suggestions on how to do it.

Can I add pdf tags to R markdown document?

I am trying to make a "accessible" or 508 compliant PDF using R markdown. To do this I need to have pdf tags attached to figure that provide alternative text. I also need to be able to add tags to section headers etc.
The idea is if you open the pdf in a pdf viewer that then the tags are read in in the "table of context" and allow a user to move between sections.
If you use a markdown header like
# header
R markdown seems to add a label to this so it appear in the table of context. I would like to be able to add these kind of labels manually as well.
Does anyone have any ideas of how to do this?
You should be able to achieve this using pandoc formatting (see http://pandoc.org/MANUAL.html), for example the alt text for an image can be specified as ![alt text or image title](path/to/image)

Knitting R Markdown to PDF Image Embedding issue

When I try to embed successive images in my .Rmd document, the first one will work fine, but the second one will not be there but whatever I say after it is. So my code will look something like this:
![caption](image1.png)
Words, words, and more words
![caption](image2.png)
Again more words
The knitted document will look something like this if you can imagine it:
PAGE 1:
image1 with caption
Words, words, and more words
Again, more words
PAGE 2:
image2 with caption
I would want image 2 to be above "Again, more words" but it skips a page. The image would certainly fit on the page, and I've tried every small formatting thing I know with R markdown. But, the only remedy that works but is ugly is to include a page break after each image, which leaves a ton of whitespace on the page. Thanks in advance.

In RMarkdown Word document, how to make table of contents appear later

When an RMarkdown document is knit to Word, the Table of Contents (if there is one) always appears at the beginning of the document. If I want to, say, make the Table of Contents appear on the second page of the document, how do I do so?
If I was knitting to HTML I could use this method, but it doesn't seem to work for Word. Meaning, I create a Word template to be used in the reference_docx YAML argument and put the Table of Contents at the bottom of this template, but when I knit a report the Table of Contents appears at the front of the document.
Preferably, I'd like to use a solution that doesn't rely on VBA/VBS and instead uses RMarkdown and (if necessary) a reference_docx file only.
As explained here, based on this and this, you could change the style of the date in the Word document to add a page break after it.
Of course, that only separates the title page from the table of contents and if you want to insert other pages between those two, it wouldn't work.
But at least that's an idea to start from.
I've just been playing around with this issue myself. Unfortunately, I don't think Word allows you to modify a style to insert a break after a style, only before.
However, the TOC header is a style that is created when a TOC is included and can be modified. If you change the TOC header style to include a page break before, save this as your reference style document and run it forces the TOC onto a new page when knit.
As #Ben notes though this only allow you to move the TOC off the title page, not insert it where you want within the document.
I was searching for a solution to this today and came across Garrick Aden‑Buie's blog post and render_toc() function.
Full details of which can be found here or his gist
This function allowed me to move the TOC later in to the document.

Resources