So I can't for the life of me including this dsfont package in R Markdown. I really want to use the double-stroke letters.
I include it in the header like so:
header-includes:
- \usepackage{dsfont}
And I use $\mathds{P}$, for example to denote probability.
The file knit fine with no error but the HTML output is \mathdsP, i.e. it doesn't work.
I tried downloading the dsfont zip directly from CTAN but when I click download nothing happens.
What do I need to do to make this work?
\usepackage is a command for PDF output.
It is not possible to use dsfont with HTML output.
Related
I've started using knitr (without pander) and I'm very impressed.
I can find instructions for writing inline knitr markdown – which will be processed even though a hash is written at the beginning of a line (which will be useful). However, it has occurred to me that if knitr can read and process such information, perhaps there is a way to write ALL markdown instructions e.g. ```{r} with a hash at the beginning of the line ? I.e., I would like it if ##```{r} also worked when run via knit.
This would allow me to create files which work without errors when run using R console and also when run via knit – which might be useful when files are submitted for review.
I have found this latex template,
http://www-h.eng.cam.ac.uk/help/tpl/textprocessing/ThesisStyle/
which is perfect for my thesis. I am currently writing it directly in Latex with TexStudio, and playing around with the template directly is easy.
I am however switching to RStudio and wiriting it as a RNotebook, as I need to be able to easily produce docx versions of it (or other formats).
I already produced a Rmd version which works perfectly as a html/docx, but the pdf it produces (and i tried bookdown, thesisdown, oxfordown etc..) is never as good looking as the template above.
Is there a way to "extract" a template from the latex template in the link, which can be used for the pandoc conversion in RStudio? How?
(i am quite a newbie so please try with an easy accessible answer!)
I haven't been able to use the neater knitter package with the code chunks.
Basically there's only a few number of occasions in which it interprets them well, but for the most of it the chunks are not recognized as such. That is:
Running a markdown from RStudio only renders chunks before the file is saved. If the file has been saved, then it will show the code as is: no R output.
I also tried using knitr from within LyX, and this presented other problems. The simplest example knitr.lyx was rendered correctly as a pdf, but not html. Using more complicated documents, like the RJournal template showed other errors.
Rscript --verbose --no-save --no-restore
At first I thought it had to do with my Rstudio installation, but now I'm not so sure anymore.
By the way, I'm on Ubuntu 15.04 and the files that I'm using are examples from the documentation:
Rstudio > New File > Rmarkdown... renders R output only before it's saved.
knitr's manual in LyX from Github repo.
I found the answer for this.
It's very obvious and yet easy to overlook if you don't know it.
The problem was in saving the file with the wrong extension.
If you're using R code chunks you need .Rmd extension in Rstudio.
As I was starting with markdown I was using .md. Pfff.
all
Ufff... I believe I did my hw to research this and still don't have an answer so asking all:
I have R-Studio, valid RMD file, when I tried to I don't get new .pdf file, I have viewer which is still html.
No problem to create HTML, it works fine, but I need pdf.
tried to use render ("file.RMD", "file.PDF") to find that I don't have render, tried install pandoc, got an error < package ‘pandoc’ is not available (for R version 3.1.2)>
so what is the simple way to get that pdf, why my doesn't work as desinged? what I'm missing I put that info into header too...
output: pdf_document
Im totaly lost, appreciate help.
render("Proj1.RMD", "Proj1.pdf")
Best
Mario
I'm aware that R markdown can produce superscripts:
text^superscript
But is it possible to produce proper subscripts? Or is the only way to do so to cheat and use LaTeX math mode:
$\sf{text_{subscript}}$
The intended final output is HTML.
R Markdown subscript is working normally as it should.
Maybe this is an old post. I'm using RStudio Version 0.99.902 + R Version 3.4 on a Mac.
Subscript: H~2~O is a liquid.
Superscript: 2^10^ is 1024.
Since you mention Pandoc in your comments, maybe it's not cheating to depend on Pandoc's extensions for subscript and superscript. From here, we can create a minimal example Rmd file:
Testing Subscript and Superscript
========================================================
This is an R Markdown document.
Pandoc includes numerous extensions to markdown, and one
of them is *subscript* and *superscript*.
Here's the example from the Pandoc help page
(http://johnmacfarlane.net/pandoc/README.html#superscripts-and-subscripts):
H~2~O is a liquid. 2^10^ is 1024.
For fun, here's an R code block with some code from #Spacedman:
```{r}
list.depth <- function(this, thisdepth = 0) {
# http://stackoverflow.com/a/13433689/1270695
if(!is.list(this)) {
return(thisdepth)
} else {
return(max(unlist(lapply(this, list.depth, thisdepth = thisdepth+1))))
}
}
```
Using Knitr results in an HTML file that renders like this:
That clearly doesn't work. But you can run pandoc on the resulting markdown file (which I've named "Subscripts.md"):
pandoc -o Subscripts.html Subscripts.md -s -S
and you'll get this:
The CSS is different, but perhaps you can call pandoc with a custom CSS argument to use the same CSS used by Knitr.
Subscripts in PDF files also work as expected with that markdown file:
pandoc -o Subscripts.pdf Subscripts.md
Edit
If you want the pandoc output to match the visual appearance of the output when you knit with RStudio, download the CSS file that RStudio uses here and make a reference to that file when you create your HTML file from pandoc. (The following assumes you have kept the name as markdown.css an it is in the same directory as your other files.)
pandoc -o Subscripts.html Subscripts.md -s -S --css=markdown.css
I found that the X~j~ syntax for subscripts works fine in Rmarkdown when knitting in RStudio. However, it does not work if you embed knitting in a shiny app. In my app,
knit2html("Steps.Rmd")
browseURL("Steps.html")
works fine except for the subscripts.
But vanilla HTML subscript syntax will work in your Rmd document for both RStudio and from within a shiny app: X<sub>j</sub> renders as Xj.
For R version 4.0.2 (2020-06-22) this works for me:
Subscript H~2~O~
Superscript R^2^