Debian Codegraph @

texmf-dist/doc/latex/amnestyreport/sample.Rmd

raw
1 ---
2 title: "RMarkdown report example"
3 subtitle: "An example report for Amnesty output"
4 titleimage: "BoschFragment"
5 titleimagecaption: "The Garden of Earthly Delights is the modern title
6 given to a triptych oil painting on oak panel painted by the Early
7 Netherlandish master Hieronymus Bosch, between 1490 and 1510, when
8 Bosch was between 40 and 60 years old. It has been housed in the
9 Museo del Prado in Madrid, Spain since 1939.\n\n
10 \\textcopyright{} Image: Public domain.\n\n
11 \\textcopyright{} Caption: Wikipedia contributors, 2023, released
12 under Creative Commons Attribution-ShareAlike License 4.0"
13 copyrightyear: 2023
14 firstpublicationyear: 2022
15 reportindex: ABXC/AAAA/2022
16 blurb: "This sample output of Rmarkdown with TeX shows the general
17 commands and options of the amnestyinternational TeX class. It is based
18 on the text by Jule Krueger."
19
20 output:
21 pdf_document:
22 template: amnestytemplate.tex
23 latex_engine: xelatex
24 toc: true
25 keep_tex: true
26 citation_package: natbib
27 classoption: freefonts, nologo
28 header-includes:
29 - \renewcommand{\thesection}{\Alph{section}}
30 bibliography: "examplereferences.bib"
31 vignette: >
32 %\VignetteIndexEntry{amenstyreportR}
33 %\VignetteEngine{knitr::rmarkdown}
34 %\VignetteEncoding{UTF-8}
35 ---
36 ```{r setup, include=FALSE}
37 library(amnestyreportR)
38 setup_amnesty_plots(options='freefonts, nologo')
39 # use
40 # setup_amnesty_plots(draft=TRUE)
41 # to make fast draft plots
42 library(knitr)
43 library(tidyr)
44 library(dplyr)
45 library(ggplot2)
46 ```
47
48
49 \begin{AmnestyGlossary}[10em]
50 Commute &
51 Commute means to replace a punishment, usually a death sentence, with a less severe one. For example, Amnesty called for the USA to commute to time served the 35-year jail sentence of whistleblower Chelsea Manning, who had been arrested after leaking classified government material
52 \\
53 Crimes against humanity &
54 When certain acts---including murder, torture and slavery---form part of a widespread attack on a civilian population by a state or organization. Unlike war crimes, they can take place at times of peace as well as during conflict. The Rwandan genocide of 1994 is one example of a crime against humanity.
55 \\
56 Extrajudicial executions &
57 Unlawful killings ordered by a government, or committed with its knowledge and support. They can be carried out by the military, police, or by civilians working with government forces. For example, Hamas forces in Gaza committed serious human rights abuses, including extrajudicial executions, torture and abductions, during the 2014 Gaza/Israel conflict.
58 \\
59 Freedom of expression &
60 The right to seek, receive and share information and ideas, without fear or interference. It is closely linked with freedom of association (the right to meet with anyone you choose, for example, to form and join clubs, societies or trade unions) and the right to take part in a peaceful assembly, such as a demonstration or public meeting.
61 \\
62 Immunity (from prosecution) &
63 Allows an accused person to avoid prosecution for a crime because of their job or office. Amnesty International is opposed to immunity. For example, Amnesty has called for the rejection of immunity in the Central African Republic so that people who committed crimes during conflict there are brought to justice.
64 \\
65 Impunity &
66 Impunity is when people who have committed crimes avoid punishment. For example, there is a ‘culture of impunity’ among police in the Philippines, who are able to torture people without fear of being punished. Amnesty calls for these people to be tried and sentenced fairly, according to the law.
67 \\
68 Prisoner of conscience &
69 A prisoner of conscience is someone who is imprisoned because of who they are (sexual orientation, ethnic, national or social origin, language, birth, colour, sex or economic status) or their religious, political or other beliefs, and who hasn’t used or advocated violence. For example, Dr Mohammed al-Roken is a current prisoner of conscience in the United Arab Emirates, jailed for 10 years following a deeply unfair trial.
70 \\
71 War crimes &
72 War crimes are serious crimes committed during armed conflicts, which could include murdering prisoners of war, killing hostages, torture and destroying towns and villages. A recent example is in the Ukraine, where there is overwhelming evidence of ongoing war crimes, including torture and summary killings of prisoners.
73 \\
74 \end{AmnestyGlossary}
75
76 From \url{https://www.amnesty.org/en/latest/campaigns/2015/07/beginners-guide-human-rights-jargon/}
77
78 \clearpage
79 # Introduction {.unnumbered}
80
81 In this document we discuss the use of `amnestyreport.cls`, and accompanying `R` package \& `pandoc` template for writing Amnesty International Reports.
82
83 You can either use an `Rnw` file with \LaTeX\ syntax, or an `Rmd` file with R Markdown syntax. In both cases you need:
84
85 * The \LaTeX\ class file `amnestyreport.cls`,
86 * A properly installed `R` package `amnestyreportR`,
87 * Optionally Amnesty International fonts and logo (see below).
88
89 If you use R Markdown syntax rather than \LaTeX\ syntax, you also need
90
91 * The `pandoc` template `amnestytemplate.tex`
92
93 ## A note about the fonts and logos {.unnumbered}
94
95 If you have an established relationship with Amnesty International, you may use their fonts and logos in your report. You need to install the fonts, and the file with the logo (rename it to `Amnesty_logo.png`). Otherwise you need the options `freefonts, nologo` in your preamble for \LaTeX\ or the line
96 `classoption: freefonts, nologo` in the RMD preamble.
97
98 ## Rmd premable example {.unnumbered}
99
100 If you use Rmd, you need to specify in your preamble that
101
102 * You are using the template `amnestytemplate.tex` rather than the generic `pandoc` template;
103 * You are using `xelatex` (or `lualatex`) rather than a 8-bit engine `podflatex`.
104
105 For example this file has the following preamble:
106
107
108 ```
109 ---
110 title: "RMarkdown report example"
111 subtitle: "An example report for Amnesty output"
112 titleimage: "BoschFragment"
113 titleimagecaption: "The Garden of Earthly Delights is the modern title
114 given to a triptych oil painting on oak panel painted by the Early
115 Netherlandish master Hieronymus Bosch, between 1490 and 1510, when
116 Bosch was between 40 and 60 years old. It has been housed in the
117 Museo del Prado in Madrid, Spain since 1939.\n\n
118 \\textcopyright{} Image: Public domain.\n\n
119 \\textcopyright{} Caption: Wikipedia contributors, 2023, released
120 under Creative Commons Attribution-ShareAlike License 4.0"
121 copyrightyear: 2023
122 firstpublicationyear: 2022
123 reportindex: ABXC/AAAA/2022
124 blurb: "This sample output of Rmarkdown with TeX shows the general
125 commands and options of the amnestyinternational TeX class. It is based
126 on the text by Jule Krueger."
127
128 output:
129 pdf_document:
130 template: amnestytemplate.tex
131 latex_engine: xelatex
132 toc: true
133 keep_tex: true
134 citation_package: natbib
135 classoption: freefonts, nologo
136 header-includes:
137 - \renewcommand{\thesection}{\Alph{section}}
138 bibliography: "examplereferences.bib"
139 ---
140 ```
141
142 \clearpage
143
144 # Cross-references and bibliography \label{cross-ref}
145
146 You can use the standard \LaTeX\ and R Markdown facilities for references.
147
148 The package uses `biblatex` with the `bibtex` backend for citations to provide footnote citations, [See @SecondRef2022]\textsuperscript{,}[See also @FirstRef2023, p.12] and [@FirstRef2023, p. 23]. However, due to idiosyncrasies of `pandoc` we need to specify `natbib` as the citation engine in the preamble. Never mind biblatex warnings during the processing.
149
150
151 Below in \autoref{sec:figures_tables} we show the examples of tables and figures provided by the package.
152
153
154 # Figures and tables \label{sec:figures_tables}
155
156 ## Inline expressions
157
158 Irises are beautiful flowers that come in different types, shapes and sizes. In this report, we look at different species of irises in terms of petal size.\footnote{This is how you can add a footnote. Some footnotes are very long, and some are several lines log, but this is OK. Just make sure the indentation is right.}
159
160
161 We define the variable `N_iris` and use it inline in the following example:
162
163 ```{r total_number_iris}
164 N_iris <- nrow(iris)
165 ```
166
167 There are a total of `r N_iris` (coded as \texttt{`}\texttt{r N\_iris}\texttt{`}) iris flower specimen in the built-in \textbf{iris} data.
168
169
170
171 ## A table
172
173 Here is an example of a table using `kable` package and `amnesty_table` function:
174
175
176 ```{r example_table, eval=FALSE}
177 iris %>%
178 count(Species) %>%
179 mutate(percent = n/sum(n)*100) %>%
180 bind_rows(summarise(., across(where(is.numeric), sum),
181 across(where(is.factor), ~'Total'))) %>%
182 amnesty_table(row.names = FALSE,
183 align = "lrr",
184 caption="\\label{tab:species}
185 Frequency distribution of iris species.",
186 position="!ht",
187 col.names = c("Species", "Number of species", "(%)"),
188 digits=2) %>%
189 kableExtra::row_spec(4, bold=TRUE)
190 ```
191
192 We can typeset it with sideways caption using `\sideTableCaptions`:
193 \sideTableCaptions
194
195 ```{r example_table, echo=FALSE, eval=TRUE}
196 ```
197
198 Alternatively, we can typeset it with normal captions using `\normalTableCaptions`:
199 \normalTableCaptions
200 ```{r example_table_1, echo=FALSE}
201 iris %>%
202 count(Species) %>%
203 mutate(percent = n/sum(n)*100) %>%
204 bind_rows(summarise(., across(where(is.numeric), sum),
205 across(where(is.factor), ~'Total'))) %>%
206 amnesty_table(row.names = FALSE,
207 align = "lrr",
208 caption="\\label{tab:species1}
209 Frequency distribution of iris species.",
210 position="!ht",
211 col.names = c("Species", "Number of species", "(%)"),
212 digits=2) %>%
213 kableExtra::row_spec(4, bold=TRUE)
214 ```
215
216
217
218 \FloatBarrier
219
220 ## Figures
221
222 Normally the figures are prepared in separate \LaTeX\ runs. This might be very slow, so you may want to use the draft mode for the editing runs. Before making the figures, you need to issue the `R` command `setup_amnesty_plots(options=..., draft=...)`. The `options` are those that are passed to \LaTeX\ class; if you do not have Amnesty International fonts, use `freefonts`. The `draft` can be either `TRUE` or `FALSE` (for quick plots). For example
223
224 ```{r setup_example, eval=FALSE}
225 setup_amnesty_plots() # You have Amnesty fonts and logo
226 setup_amnesty_plots(options='freefonts, nologo') # No Amnesty fonts
227 setup_amnesty_plots(draft=TRUE) # Draft mode
228 ```
229
230 We are using the \textit{ggplot2} package to make an example figure from the built-in iris data. As can be seen in \autoref{fig:species-petal-size}, the virginica species of iris has the largest petal size in comparison to the other two iris species. Note that it is recommended to use both color and line shape to convey the same information for the benefit of color blind users.
231
232 ```{r species-petal-size, echo=FALSE, fig.cap="Distribution of petal length and petal width, by iris species.", fig.align="center", fig.height = 3, fig.width = 6}
233 iris %>%
234 ggplot(aes(x=Petal.Length, y=Petal.Width, color=Species, fill=Species,
235 shape=Species)) +
236 geom_point() +
237 xlab("Petal Length") + ylab("Petal Width")
238 ```
239
240
241
242 We use viridis scale optimized for color blind users both for the discrete (\autoref{fig:species-petal-size}) and continuous (\autoref{fig:petal-size-sepal-size}) scales. We also use `\sideFigureCaptions` to typeset the caption on the side
243 \sideFigureCaptions
244
245 ```{r, petal-size-sepal-size, fig.cap="Distribution of petal and sepal sizes", fig.align="center", fig.height = 3, fig.width = 4, echo=FALSE}
246 iris %>% ggplot + geom_point(aes(Petal.Length, Petal.Width, color=Sepal.Length)) +
247 labs(x="Petal Length", y="Petal Width", colour="Sepal Length")
248 ```
249
250 \clearpage
251
252 # Other typographic features
253
254 ## A subsection heading
255
256 ### A subsubsection heading
257
258 #### A subsubsubsection heading
259 We have line break after a subsubsubsection heading as Amnesty style requires.
260
261 #### Type of iris species (Species)
262 This variable indicates the different botanical types of iris species.
263
264 \begin{description}
265 \item[\textbf{setosa:}] The iris belongs to the botanical species of setosa.
266 \item[\textbf{versicolor:}] The iris belongs to the botanical species of versicolor.
267 \item[\textbf{virginica:}] The iris belongs to the botanical species of virginica.
268 \end{description}
269
270
271 An example of a quotation.
272
273 > All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood.
274 >
275 > \attribution{Universal Declaration of Human Rights}
276
277