List of figures with bookdown::word_document2 and rmarkdown - ms-word

Is there a way of creating a list of figures/tables with bookdown and Rmarkdown when outputting to word_document2?
With the pdf/latex, adding to the yaml header works:
lot: true
lof: true
But I can't figure out how to have it in a word document.

Related

Why doesn't the table generated from r-exams appear in Moodle?

I have defined the variables and data necessary to generate a frequency table in RMarkdown, to export it to Moodle, using R-exams:
xsubio<-c(sample(5:35,5))
xsubi<-sort(xsubio)
frecuencias<-sample(0:30 ,5)
tabla<-data.frame(xsubi,frecuencias)
colnames(tabla)<-c(" Edades" ,"Personas")
Through chunk I generate the table:
```{r, eval=TRUE,echo=FALSE,results='asis',warning=FALSE,message=FALSE,error=FALSE}
library(exams)
print(xtable(tabla), include.rownames=FALSE)
```
When exporting to PDF, using exams2pdf, the table is displayed perfectly:
But, when exporting to Moodle, using exams2moodle, the table disappears:
What do I have to do to make it appear?
Problem: You have an exercise with formatting in Markdown and use xtable() to insert a table in LaTeX. This mixture of Markdown+LaTeX is no problem when converting the exercise to PDF. Internally, this preserves the LaTeX table and just converts the Markdown parts to LaTeX as well before rendering the LaTeX to PDF. However, the same is not possible automatically when converting the Markdown exercise to HTML for Moodle. The converter then does not separate the LaTeX part automatically to convert it to HTML.
In short: The different markups must be sufficiently in sync. Markdown+LaTeX markup for PDF output works and Markdown+HTML for HTML output works. But what would be even better is to have the markup fully in sync, i.e., LaTeX+LaTeX or Markdown+Markdown. Such exercises can then be rendered to either PDF or HTML automatically.
Possible solutions:
Markdown+Markdown: Markdown table markup in R/Markdown (Rmd) exercise
I would recommend that you simply produce tables in Markdown via knitr::kable() rather than xtable::xtable(). Thus, the code chunk for the table simply becomes
knitr::kable(tabla, format = "markdown")
and then the tables are rendered correctly in both PDF and HTML-based formats like Moodle.
LaTeX+LaTeX: LaTeX table markup in R/LaTeX (Rnw) exercise
In case you prefer to keep on generating LaTeX tables with xtable() another route would be to change the markup of the R/exams exercise to Rnw (R/LaTeX). See the First steps tutorial on the R/exams web page for how to do that.
Markdown+Adaptive: Choose the right table markup depending on the output format
Using the match_exams_call() function you can determine in a running exercise which exams2xyz() interface is being used to process it. So you could do
type <- if(match_exams_call() %in% c("exams2pdf", "exams2nops")) "latex" else "html"
print(xtable(tabla), type = type, ...)
Then either LaTeX or HTML format is produced by xtable().
All three solutions work in principle but I think Solution 1 (kable()) is the best and most robust in your case.
Bonus remark: If you are using R/exams >= 2.4-0 you can use exams2moodle(...,table = TRUE) to get nicer table formatting in Moodle.
I use the following code snippet (with type = "latex"), when I require a PDF output:
```{r, eval=TRUE, only.contents=TRUE, echo=FALSE, results='asis',
warning=FALSE, message=FALSE, error=FALSE, comment=FALSE}
library(exams)
library(xtable)
print(xtable(tabla), include.rownames=FALSE, type = "latex", comment=F)
```
And, when I require outputs for Moodle, I make use of the following code snippet (with type = "html"):
```{r, eval=TRUE, only.contents=TRUE, echo=FALSE, results='asis',
warning=FALSE, message=FALSE, error=FALSE, comment=FALSE}
library(exams)
library(xtable)
print(xtable(tabla), include.rownames=FALSE, type = "html",
comment=F)
```
Results in PDF:
Results for Moodle:

refman.rtf fails to use equation from '*.md' in doxygen

I use '.md' to generate '(index).html' and '(refman*).rtf' documentation with doxygen 1.8.14.
The mathematical equation in '*.md' gives a correct equation in html output but not in the file 'refman.rtf'. The other theoretical parts like paragraph and other stuff work well between *.md and rtf output.
I guess *.rtf is not recognizing the equation part of the *.md document.
Does the RTF generation through doxygen read the *.md files?
Do I need to change any tag to make *.md work with rtf output?
Not only for markdown but also for "normal" doxygen input formulas do not work.
From the documentation:
Doxygen allows you to put LATEX formulas in the output (this works
only for the HTML and LATEX output, not for the RTF nor for the man
page output).
A workaround workflow, at the moment for non inline formulas, is to do something like:
Create an image with the formula e.g in a dummy doxygen run where one does not use MATHJAX, this will result in an image with a name like: 'form_0.png'.
In the code one has to place an if construct like:
\if rtf_run
\image rtf form_0.png
\else
\f... with the formula
\endif
One now has to run doxygen twice:
once for the output without rtf, i.e. without setting rtf_run in ENABLED_SECTIONS
once for rtf output by setting rtf_run in ENABLED_SECTIONS
EDIT June 5, 2018: I've just pushed a proposed patch to github pull request 756. Here the formulas are rendered as png images and included in the RTF documentation.
EDIT: 2018/06/10: The push request has been integrated in the master version on github.

How to get list Level in Word(with Pandoc+Markdown)

I'm trying Pandoc with Markdown to Make various Documents.
I built a Word(.docx) Document from a Markdown document but that document get no nest at lists, example below images.
Exsample
Markdown document source is here.
* contentA
+ contentA-1
+ contentA-2
- contentA-2-1
As you can See, Left tab is OK, but indent is not working.
I want to get lists with indent.
Please Tell me how to get indented list on Pandoc.
If you notice in your screenshot, the lines in your list are separated with a line break rather than a new paragraph. So that's why there is no nesting on subsequent lines; each is considered a continuation of the first list item.
Try using the "loose" list format in pandoc's markdown. That should format each line of your list as a separate paragraph, which should make them nest properly.
Later, that same evening...
Hmm. Perhaps I was wrong. I just copy/pasted your markdown into a new file and converted it to docx and it nested just fine for me.
This was just using a simple:
pandoc -f markdown -t docx -o test_nested_lists.docx test_nested_lists.md

Making Word documents independent of their linked templates

At the office we are using several custom Word 2007 / 2010 templates. If we then send out doc files to clients they sometimes appear quite messy and ugly unformatted, as they do not have these templates on their machines.
Is there a way to embed templates into Word documents or kind of "flatten" these documents so they are not depending on the templates anymore and have formatting, images etc. all contained within just the Word doc file without needing the template anymore?
btw: I know printing the doc into a pdf and sending this would be a workaround, but we need to keep it in word, as clients have to be able to edit the documents.
This macro will break the link between a document and its template:
Sub DivorceFromTemplate()
' Dissassociates the document from its Word Template
With ActiveDocument
.UpdateStylesOnOpen = False
.AttachedTemplate = ""
End With
End Sub

How to include excel chart in mail merge

just i want include chart from excel to mail merge(ms word).i can include any fields from excel but i cant add chart to the mail merge.How that can be done Is any other possible ways.
Embed or link the Excel chart in the Word merge document as you would in a normal Word file, e.g. copy the Excel chart, and paste it into Word as an object, image or link. The place your mail merge fields as desired and complete the merge.