summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/amnestyreport/sample.Rmd
blob: 07de47664d4892285ede948f246d25d709515c5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
---
title: "RMarkdown report example"
subtitle: "An example report for Amnesty output"
titleimage: "BoschFragment"
titleimagecaption: "The Garden of Earthly Delights is the modern title
given to a triptych oil painting on oak panel painted by the Early
Netherlandish master Hieronymus Bosch, between 1490 and 1510, when
Bosch was between 40 and 60 years old. It has been housed in the
Museo del Prado in Madrid, Spain since 1939.\n\n
\\textcopyright{} Image: Public domain.\n\n
\\textcopyright{} Caption:  Wikipedia contributors, 2023, released
under  Creative Commons Attribution-ShareAlike License 4.0"
copyrightyear: 2023
firstpublicationyear: 2022
reportindex: ABXC/AAAA/2022
blurb: "This sample output of Rmarkdown with TeX shows the general
commands and options of the amnestyinternational TeX class.  It is based
on the text by Jule Krueger."

output: 
  pdf_document:
    template: amnestytemplate.tex
    latex_engine: xelatex
    toc: true
    keep_tex: true
    citation_package: natbib
classoption: freefonts, nologo
header-includes:
  - \renewcommand{\thesection}{\Alph{section}}
bibliography: "examplereferences.bib"
vignette: >
  %\VignetteIndexEntry{amenstyreportR}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---
```{r setup, include=FALSE}
library(amnestyreportR)
setup_amnesty_plots(options='freefonts, nologo')
# use
# setup_amnesty_plots(draft=TRUE)
# to make fast draft plots
library(knitr)
library(tidyr)
library(dplyr)
library(ggplot2)
```


\begin{AmnestyGlossary}[10em]
Commute &
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
\\
Crimes against humanity &
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.
\\
Extrajudicial executions &
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.
\\
Freedom of expression &
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.
\\
Immunity (from prosecution) &
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.
\\
Impunity &
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.
\\
Prisoner of conscience &
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.
\\
War crimes &
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.
\\
\end{AmnestyGlossary}

From \url{https://www.amnesty.org/en/latest/campaigns/2015/07/beginners-guide-human-rights-jargon/} 

\clearpage
# Introduction {.unnumbered}

In this document we discuss the use of `amnestyreport.cls`, and accompanying `R` package \& `pandoc` template for writing Amnesty International Reports.  

You can either use an `Rnw` file with \LaTeX\ syntax, or an `Rmd` file with R Markdown syntax. In both cases you need:

* The \LaTeX\ class file `amnestyreport.cls`,
* A properly installed `R` package `amnestyreportR`,
* Optionally Amnesty International fonts and logo (see below).

If you use R Markdown syntax rather than \LaTeX\ syntax, you also need

* The `pandoc` template `amnestytemplate.tex`

## A note about the fonts and logos {.unnumbered}

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 
`classoption: freefonts, nologo` in the RMD preamble.  

## Rmd premable example {.unnumbered}

If you use Rmd, you need to specify in your preamble that

* You are using the template `amnestytemplate.tex` rather than the generic `pandoc` template;
* You are using `xelatex` (or `lualatex`) rather than a 8-bit engine `podflatex`.

For example this file has the following preamble:


```
---
title: "RMarkdown report example"
subtitle: "An example report for Amnesty output"
titleimage: "BoschFragment"
titleimagecaption: "The Garden of Earthly Delights is the modern title
given to a triptych oil painting on oak panel painted by the Early
Netherlandish master Hieronymus Bosch, between 1490 and 1510, when
Bosch was between 40 and 60 years old. It has been housed in the
Museo del Prado in Madrid, Spain since 1939.\n\n
\\textcopyright{} Image: Public domain.\n\n
\\textcopyright{} Caption:  Wikipedia contributors, 2023, released
under  Creative Commons Attribution-ShareAlike License 4.0"
copyrightyear: 2023
firstpublicationyear: 2022
reportindex: ABXC/AAAA/2022
blurb: "This sample output of Rmarkdown with TeX shows the general
commands and options of the amnestyinternational TeX class.  It is based
on the text by Jule Krueger."

output: 
  pdf_document:
    template: amnestytemplate.tex
    latex_engine: xelatex
    toc: true
    keep_tex: true
    citation_package: natbib
classoption: freefonts, nologo
header-includes:
  - \renewcommand{\thesection}{\Alph{section}}
bibliography: "examplereferences.bib"
---
```

\clearpage

# Cross-references and bibliography \label{cross-ref}

You can use the standard \LaTeX\ and R Markdown facilities for references.  

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.


Below in \autoref{sec:figures_tables} we show the examples of tables and figures provided by the package.


# Figures and tables \label{sec:figures_tables}

## Inline expressions

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.}


We define the variable `N_iris` and use it inline in the following example:

```{r total_number_iris}
N_iris <- nrow(iris)
```

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.



## A table

Here is an example of a table using `kable` package and `amnesty_table` function:


```{r example_table, eval=FALSE}
iris %>% 
  count(Species) %>% 
  mutate(percent = n/sum(n)*100) %>% 
  bind_rows(summarise(., across(where(is.numeric), sum),
                      across(where(is.factor), ~'Total'))) %>% 
  amnesty_table(row.names = FALSE,
                align = "lrr",
		caption="\\label{tab:species}
		Frequency distribution of iris species.",
		position="!ht",
		col.names = c("Species", "Number of species", "(%)"),
		digits=2) %>%
  kableExtra::row_spec(4, bold=TRUE)
```

We can typeset it with sideways caption using `\sideTableCaptions`:
\sideTableCaptions

```{r example_table, echo=FALSE, eval=TRUE}
```

Alternatively, we can typeset it  with normal captions using `\normalTableCaptions`:
\normalTableCaptions
```{r example_table_1, echo=FALSE}
iris %>% 
  count(Species) %>% 
  mutate(percent = n/sum(n)*100) %>% 
  bind_rows(summarise(., across(where(is.numeric), sum),
                      across(where(is.factor), ~'Total'))) %>% 
  amnesty_table(row.names = FALSE,
                align = "lrr",
		caption="\\label{tab:species1}
		Frequency distribution of iris species.",
		position="!ht",
		col.names = c("Species", "Number of species", "(%)"),
		digits=2) %>%
  kableExtra::row_spec(4, bold=TRUE)
```



\FloatBarrier

## Figures

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

```{r setup_example, eval=FALSE}
setup_amnesty_plots()  # You have Amnesty fonts and logo
setup_amnesty_plots(options='freefonts, nologo') # No Amnesty fonts
setup_amnesty_plots(draft=TRUE) # Draft mode
```

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.

```{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}
iris %>% 
  ggplot(aes(x=Petal.Length, y=Petal.Width, color=Species, fill=Species,
  shape=Species)) +
  geom_point() + 
  xlab("Petal Length") + ylab("Petal Width") 
```



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
\sideFigureCaptions

```{r, petal-size-sepal-size, fig.cap="Distribution of petal and sepal sizes", fig.align="center", fig.height = 3, fig.width = 4, echo=FALSE}
iris %>% ggplot + geom_point(aes(Petal.Length, Petal.Width, color=Sepal.Length)) +
labs(x="Petal Length", y="Petal Width", colour="Sepal Length")
```

\clearpage

# Other typographic features

## A subsection heading

### A subsubsection heading

#### A subsubsubsection heading
We have line break after a subsubsubsection heading as Amnesty style requires.

#### Type of iris species (Species)
This variable indicates the different botanical types of iris species. 

\begin{description}
\item[\textbf{setosa:}] The iris belongs to the botanical species of setosa. 
\item[\textbf{versicolor:}]  The iris belongs to the botanical species of versicolor. 
\item[\textbf{virginica:}] The iris belongs to the botanical species of virginica. 
\end{description}


An example of a quotation.

> 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.
> 
> \attribution{Universal Declaration of Human Rights}