skeleton.Rmd 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. ---
  2. title: A demonstration of the \LaTeX class file for Statistics in Medicine with Rmarkdown
  3. author:
  4. - name: A. Uthor*
  5. num: a,b
  6. - name: O. Tro
  7. num: b
  8. - name: O. Vriga
  9. num: c
  10. address:
  11. - num: a
  12. org: Department of Incredible Research, University A, City A, Country A
  13. - num: b
  14. org: Department of Applied Things, University B, City B, Country B
  15. - num: c
  16. org: Very Important Stuff Committee, Institute C, City C, Country C
  17. corres: "*Corresponding author name, This is sample corresponding address. \\email{[email protected]}"
  18. presentaddress: This is sample for present address text this is sample for present address text
  19. authormark: Uthor \emph{et al}.
  20. articletype: Research article
  21. received: 2017-01-01
  22. revised: 2017-02-01
  23. accepted: 2017-03-01
  24. 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."
  25. keywords: Class file; \LaTeX; Statist. Med.; Rmarkdown;
  26. bibliography: bibfile.bib
  27. output: rticles::sim_article
  28. ---
  29. # The Article Header Information
  30. YAML header:
  31. ```
  32. output:
  33. rticles::sim_article:
  34. keep_tex: TRUE
  35. ```
  36. Configure the YAML header including the following elements:
  37. * `title`: Title
  38. * `author`: List of author(s) containing `name` and `num`
  39. * `address`: List containing `num` and `org` for defining `author` affiliations
  40. * `presentaddress`: Not sure what they mean with this
  41. * `corres`: Author and address for correspondence
  42. * `authormark`: Short author list for header
  43. * `received`, `revised`, `accepted`: dates of submission, revision, and acceptance of the manuscript
  44. * `abstract`: Limited to 250 words
  45. * `keywords`: Up to 6 keywords
  46. * `bibliography`: BibTeX `.bib` file
  47. * `classoption`: options of the `WileyNJD-v2` class
  48. * `longtable`: set to `true` to include the `longtable` package, used by default from `pandoc` to convert markdown to \LaTeX code
  49. ## Remarks
  50. 1. In `authormark` use _et al._ if there are three or more authors.
  51. 2. Note the use of `num` to link names and addresses.
  52. 3. For submitting a double-spaced manuscript, add `doublespace` as an option to a `classoption` line in the YAML header: `classoption: doublespace`.
  53. 4. Keywords are separated by semicolons.
  54. # The Body of the Article
  55. ## Mathematics
  56. Use mathematics in Rmarkdown as usual.
  57. ## Figures and Tables
  58. Figures are supported from R code:
  59. ```{r plot-ref, fig.cap = "Fancy Caption\\label{fig:plot}"}
  60. x = rnorm(10)
  61. y = rnorm(10)
  62. plot(x, y)
  63. ```
  64. ...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).
  65. Analogously, use Rmarkdown to produce tables as usual:
  66. ```{r, results = "asis"}
  67. if (!require("xtable")) install.packages("xtable")
  68. xt <- xtable(head(cars), caption = "A table", label = "tab:table")
  69. print(xt, comment = FALSE)
  70. ```
  71. 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`:
  72. ```
  73. header-includes:
  74. - \usepackage{ctable}
  75. ```
  76. Then, just write straight-up \LaTeX code and reference is as usual (`\ref{tab:ctable}`):
  77. ```
  78. \ctable[cap = {Short caption},
  79. caption = {A long, long, long, long, long caption for this table.},
  80. label={tab:ctable},]
  81. {cc}
  82. {
  83. \tnote[$\ast$]{Footnote 1}
  84. \tnote[$\dagger$]{Other footnote}
  85. \tnote[b]{Mistakes are possible.}
  86. }{
  87. \FL
  88. COL 1\tmark[a] & COL 2\tmark[$\ast$]
  89. \ML
  90. 6.92\tmark[$\dagger$] & 0.09781 \\
  91. 6.93\tmark[$\dagger$] & 0.09901 \\
  92. 97 & 2000
  93. \LL
  94. }
  95. ```
  96. 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.
  97. ## Cross-referencing
  98. The use of the Rmarkdown equivalent of the \LaTeX cross-reference system
  99. 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.
  100. ## Double Spacing
  101. If you need to double space your document for submission please use the `doublespace` option in the header.
  102. # Bibliography
  103. 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.
  104. Use the Rmarkdown equivalent of the \LaTeX citation system using `[@<name>]`. Example: [@Taylor1937], [@Knupp1999; @Kamm2000].
  105. To include all citation from the `.bib` file, add `\nocite{*}` before the end of the document.
  106. # Further information
  107. 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.