1

I need to add some superscript or symbols into fig.cap. I have tried "expression" function, but didn't work for me. How could I achieve it?

Thanks for any suggestions.

This in my Rmd file for example.

---
title: "Untitled"
author: ""
date: "Wednesday, September 24, 2014"
output: 
    word_document:
        fig_caption: true

---

```{r, echo=1,fig.cap=expression('The unit (% y'^-1*')')}
plot(cars)
```

My Session infor:

> sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252   
[3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C                      
[5] LC_TIME=English_Australia.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] digest_0.6.4     evaluate_0.5.5   formatR_0.10     htmltools_0.2.4 
[5] knitr_1.6        rmarkdown_0.2.46 stringr_0.6.2    tools_3.1.0     
[9] yaml_2.1.11     
Bangyou
  • 9,462
  • 16
  • 62
  • 94
  • 1
    The `?plotmath` commands only work inside the graphics device. If you want to put the title as the the `main=` title in your `plot()`, you can do that. But if you want the text/type of the document to have superscripts, then you need to add it as markup, not an expression. See: http://stackoverflow.com/questions/23424324/knitr-stop-superscript-in-r-markdown – MrFlick Sep 24 '14 at 03:40
  • 1
    LaTeX + Mathjax could be your friend here, at least it works in pdf and html output, I don't know if pandoc supports math conversion to Word. – baptiste Sep 24 '14 at 12:30

0 Answers0