skeleton.Rmd 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. ---
  2. title: A demonstration of the \LaTeX class file for Statistical Methods in Medical Research with Rmarkdown
  3. runninghead: Uthor \emph{et al}.
  4. author:
  5. - name: A. Uthor*
  6. num: 1,2
  7. - name: O. Tro
  8. num: 2
  9. - name: O. Vriga
  10. num: 3
  11. address:
  12. - num: 1
  13. org: Department of Incredible Research, University A, City A, Country A
  14. - num: 2
  15. org: Department of Applied Things, University B, City B, Country B
  16. - num: 3
  17. org: Very Important Stuff Committee, Institute C, City C, Country C
  18. corrauth: "Corresponding author name, This is sample corresponding address."
  19. email: [email protected]
  20. abstract: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ut elit odio. Donec fermentum tellus neque, vitae fringilla orci pretium vitae. Fusce maximus finibus facilisis. Donec ut ullamcorper turpis. Donec ut porta ipsum. Nullam cursus mauris a sapien ornare pulvinar. Aenean malesuada molestie erat quis mattis. Praesent scelerisque posuere faucibus. Praesent nunc nulla, ullamcorper ut ullamcorper sed, molestie ut est. Donec consequat libero nisi, non semper velit vulputate et. Quisque eleifend tincidunt ligula, bibendum finibus massa cursus eget. Curabitur aliquet vehicula quam non pulvinar. Aliquam facilisis tortor nec purus finibus, sit amet elementum eros sodales. Ut porta porttitor vestibulum. Integer molestie, leo ut maximus aliquam, velit dui iaculis nibh, eget hendrerit purus risus sit amet dolor. Sed sed tincidunt ex. Curabitur imperdiet egestas tellus in iaculis. Maecenas ante neque, pretium vel nisl at, lobortis lacinia neque. In gravida elit vel volutpat imperdiet. Sed ut nulla arcu. Proin blandit interdum ex sit amet laoreet. Phasellus efficitur, sem hendrerit mattis dapibus, nunc tellus ornare nisi, nec eleifend enim nibh ac ipsum. Aenean tincidunt nisl sit amet facilisis faucibus. Donec odio erat, bibendum eu imperdiet sed, gravida luctus turpis."
  21. keywords: Class file; \LaTeX; SMMR; Rmarkdown;
  22. classoption:
  23. - Royal
  24. - times
  25. bibliography: bibfile
  26. bibliographystyle: sageh
  27. output:
  28. rticles::sage_article:
  29. keep_tex: yes
  30. ---
  31. # The Article Header Information
  32. YAML header:
  33. ```
  34. output:
  35. rticles::sim_article:
  36. keep_tex: TRUE
  37. ```
  38. Configure the YAML header including the following elements:
  39. * `title`: Title
  40. * `runninghead`: Author last names, use _et al._ if there are three or more authors.
  41. * `author`: List of author(s) containing `name` and `num`
  42. * `corrauth`: Corresponding author's name and address.
  43. * `email`: Correspondence email
  44. * `abstract`: Limited to 200 words
  45. * `keywords`: Keywords for the article
  46. * `bibliography`: BibTeX `.bib` file
  47. * `bibliographystyle`: sageh or sagev
  48. * `classoption`: options of the `sagej` class
  49. ## Remarks
  50. 2. `bibliographystyle`
  51. 3. `classoption`
  52. 4. Keywords are separated by commas.
  53. # The Body of the Article
  54. ## Mathematics
  55. Use mathematics in Rmarkdown as usual.
  56. ## Figures and Tables
  57. Figures are supported from R code:
  58. ```{r plot-ref, fig.cap = "Fancy Caption\\label{fig:plot}", out.width='100%'}
  59. x = rnorm(10)
  60. y = rnorm(10)
  61. plot(x, y)
  62. ```
  63. ...and can be referenced (Figure \ref{fig:plot}) by including the `\\label{}` tag in the `fig.cap` attribute of the R chunk: `fig.cap = "Fancy Caption\\label{fig:plot}"`. It is a quirky hack at the moment, see [here](https://github.com/yihui/knitr/issues/323).
  64. Analogously, use Rmarkdown to produce tables as usual:
  65. ```{r, results = "asis"}
  66. if (!require("xtable")) install.packages("xtable")
  67. xt <- xtable(head(cars), caption = "A table", label = "tab:table")
  68. print(xt, comment = FALSE)
  69. ```
  70. Referenced via \ref{tab:table}. You can also use the YAML option `header-includes` to includes custom \LaTeX packages for tables (keep in mind that `pandoc` uses `longtables` by default, and it is hardcoded; some things may require including the package `longtable`). E.g., using `ctable`:
  71. ```
  72. header-includes:
  73. - \usepackage{ctable}
  74. ```
  75. Then, just write straight-up \LaTeX code and reference is as usual (`\ref{tab:ctable}`):
  76. ```
  77. \ctable[cap = {Short caption},
  78. caption = {A caption for this table.},
  79. label={tab:ctable},]
  80. {cc}
  81. {
  82. \tnote[$\ast$]{Footnote 1}
  83. \tnote[$\dagger$]{Other footnote}
  84. \tnote[b]{Mistakes are possible.}
  85. }{
  86. \FL
  87. COL 1\tmark[a] & COL 2\tmark[$\ast$]
  88. \ML
  89. 6.92\tmark[$\dagger$] & 0.09781 \\
  90. 6.93\tmark[$\dagger$] & 0.09901 \\
  91. 97 & 2000
  92. \LL
  93. }
  94. ```
  95. It is also possible to set the `YAML` option `longtable: true` and use markdown tables (or the `knitr::kable` function): `knitr::kable(head(cars))` produces the same table as the `xtable` example presented before.
  96. ## Cross-referencing
  97. The use of the Rmarkdown equivalent of the \LaTeX cross-reference system
  98. for figures, tables, equations, etc., is encouraged (using `[@<name>]`, equivalent of `\ref{<name>}` and `\label{<name>}`). That works well for citations in Rmarkdown, not so well for figures and tables. In that case, it is possible to revert to standard \LaTeX syntax.
  99. ## Double Spacing
  100. If you need to double space your document for submission please use the `doublespace` option in the header.
  101. # Bibliography
  102. Link a `.bib` document via the YAML header, and bibliography will be printed at the very end (as usual). The default bibliography style is provided by Wiley as in `WileyNJD-AMA.bst`, do not delete that file.
  103. Use the Rmarkdown equivalent of the \LaTeX citation system using `[@<name>]`. Example: [@Taylor1937], [@Knupp1999; @Kamm2000].
  104. To include all citation from the `.bib` file, add `\nocite{*}` before the end of the document.
  105. # Further information
  106. All \LaTeX enviroments supported by the main template are supported here as well; see the `.tex` sample file [here](http://onlinelibrary.wiley.com/journal/10.1002/(ISSN)1097-0258/homepage/la_tex_class_file.htm) for more details and example.