Skip to content

Commit

Permalink
Short pdf report extension for quarto (#11)
Browse files Browse the repository at this point in the history
* Test to see push to which branch

* Test to see push to which branch

* Add in the pdf short report format

* Table float option and move all include-in-head to template

* Add in the blah ref

* Add in the float option for figure

* Move the yaml block config into extension

* Fix my typo

* Turn on the makefile for short report

* Change the format to match with the extension

* Rename to pdf-report to match with Makefile

* Change the "-" in the format to "+" to enable quarto to render

* Move to the correct location

* Update the file path name
  • Loading branch information
VMT1312 authored Sep 18, 2024
1 parent f293e33 commit dcb58bb
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 68 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ asset-docx: ## Render docx report document
asset-report: ## Render pdf report document
quarto render docs/demos/template-pdf-report.qmd --output-dir assets

#asset-short-report: ## Render short pdf document
# quarto render docs/demos/template-pdf.qmd --output-dir assets
asset-short-report: ## Render short pdf document
quarto render docs/demos/template-pdf.qmd --output-dir assets

assets: asset-pdf asset-docx asset-revealjs ## Render all assets

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ For documentation on using reveal.js slides in Quarto, please see,

## Updating

As we continue to improve this extension through bug fixes or adding new functionality, you can update it easily like so:
As we continue to improve this extension through bug fixes or adding new functionality, you can update it easily like so:.

```bash
cd your_quarto_project_folder
Expand Down
33 changes: 27 additions & 6 deletions _extensions/aagi/_extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,36 @@ contributes:
chalkboard: true
execute:
echo: true
pdf-report:
template: aagi-pdf-report/aagi-pdf-report.tex
pdf+report:
template: pdf-report/aagi-pdf-report-template.tex
format-resources:
- assets/aagi_logo.pdf
- assets/partners.pdf
pdf-short-report:
template: short-_pdf-report/aagi-short-pdf-report.tex
pdf+short+report:
template: short-pdf-report/aagi-short-pdf-report.tex
fontsize: 12pt
papersize: a4
toc: false
number-sections: false
pdf-engine: xelatex
mainfont: Proxima Nova
links-as-footnotes: false
bibliography: references.bib
csl: biometrics.csl
link-citations: true
knitr:
opts_chunk:
fig.path: figure/
fig.align: center
fig.show: hold
fig.pos: H
comment: NA
background: white
highlight: false
size: small
prompt: true
format-resources:
- assets/AAGI_logo.pdf
- assets/Partners.pdf
docx-report:
reference-doc: docx-report/aagi-report-word.docx
docx+report:
reference-doc: docx-report/aagi-docx-report-template.docx
1 change: 1 addition & 0 deletions _extensions/aagi/pdf-report/aagi-pdf-report-template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
\definecolor{aagiorange}{HTML}{ec8525}
\definecolor{aagiblack}{HTML}{414042}
\definecolor{aagigrey}{HTML}{f2f2f2}
\definecolor{pagenum}{HTML}{7F7F7F}

% Colour tables + long tables
\usepackage{colortbl}
Expand Down
13 changes: 10 additions & 3 deletions _extensions/aagi/short-pdf-report/aagi-short-pdf-report.tex
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@

\usepackage[$if(papersize)$$papersize$paper,$endif$left=12mm,right=12mm,top=22mm,bottom=22mm]{geometry}

% Force placement of table
\usepackage{float}
\floatplacement{table}{H}

% Random texts
\usepackage{lipsum}

% Colours and graphics
\usepackage[dvipsnames,svgnames,x11names,table]{xcolor}
\usepackage{graphicx}
Expand Down Expand Up @@ -128,14 +135,14 @@
\fancyhf{}
\fancyhead[R]{%
\noindent\makebox[\textwidth][r]{%
\includegraphics[height=2.3cm]{aagi_logo.pdf}\hspace*{-0.5cm}}}
\includegraphics[height=2.3cm]{assets/aagi_logo.pdf}\hspace*{-0.5cm}}}
\fancyfoot[C]{%
\rule{\textwidth}{0.4pt}\\[-10pt]
\noindent\makebox[\textwidth]{%
%TODO: In here: want a YAML option for 'project-partner' or something,
% in which case we swap out the footer graphic and overlay the partner
% logo in the right place.
\includegraphics[width=\paperwidth]{partners.pdf}}}
\includegraphics[width=\paperwidth]{assets/partners.pdf}}}
\renewcommand{\headrulewidth}{0pt}}
\fancypagestyle{otherpages}{%
\fancyhf{}
Expand Down Expand Up @@ -215,7 +222,7 @@
% Authors
{\normalsize{%
$if(author)$
$for(author)$$author$$sep$, $endfor$\\[-20pt]
$for(author)$$author$$sep$\\, $endfor$\\[-20pt]
$endif$}}

% Emails
Expand Down
File renamed without changes.
11 changes: 11 additions & 0 deletions docs/demos/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,15 @@ @Article{Box1976
publisher = {Informa UK Limited},
}

@article{blah,
author = {Person, My},
journal = {My Journal},
number = {12},
pages = {pp.~12--34},
doi = {10.1000/182},
title = {My article title goes here},
volume = {13},
year = {2024}
}

@Comment{jabref-meta: databaseType:bibtex;}
10 changes: 5 additions & 5 deletions docs/demos/template-docx-report.qmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
format:
aagi-docx-report: default
aagi-docx+report: default
execute:
echo: false
knitr:
Expand All @@ -18,11 +18,11 @@ date-format: long
```{r}
#| include: false
if (params$uni == "CU") {
Project_Lead = "Curtin University -- Prof Mark Gibberd, Dr Julia Easton, Prof Adam Sparks"
project_lead = "Curtin University -- Prof Mark Gibberd, Dr Julia Easton, Prof Adam Sparks"
} else if (params$uni == "UA") {
Project_Lead = "University of Adelaide -- Dr Julian Taylor, Dr Olena Kravchuck"
project_lead = "University of Adelaide -- Dr Julian Taylor, Dr Olena Kravchuck"
} else {
Project_Lead = "University of Queensland -- Prof Scott Chapman, Emeritus Prof Kaye Basford"
project_lead = "University of Queensland -- Prof Scott Chapman, Emeritus Prof Kaye Basford"
}
```

Expand Down Expand Up @@ -67,7 +67,7 @@ subtitle: "Descriptive title for report \n Report for `r Pro_Num`"
author:
- Adam Sparks
- "Email: `r email`"
- "Project Leads: `r Project_Lead`"
- "Project Leads: `r project_lead`"
---

```{r}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
---
format:
aagi-pdf: default
aagi-pdf+report: default
execute:
echo: false
knitr:
opts_chunk:
fig.path: figures/
fig.pos: H
params:
uni: CU
pri_bio: Your.Name
Expand All @@ -19,11 +20,11 @@ editor: visual
#| label: param_uni
if (params$uni == "CU") {
Project_Lead = "Curtin University -- Prof Mark Gibberd, Dr Julia Easton, Prof Adam Sparks"
project_lead = "Curtin University -- Prof Mark Gibberd, Dr Julia Easton, Prof Adam Sparks"
} else if (params$uni == "UA") {
Project_Lead = "University of Adelaide -- Dr Julian Taylor, Dr Olena Kravchuck"
project_lead = "University of Adelaide -- Dr Julian Taylor, Dr Olena Kravchuck"
} else {
Project_Lead = "University of Queensland -- Prof Scott Chapman, Emeritus Prof Kaye Basford"
project_lead = "University of Queensland -- Prof Scott Chapman, Emeritus Prof Kaye Basford"
}
```

Expand Down Expand Up @@ -93,7 +94,7 @@ Pro_Num = params$project_num
% \textbf{Email:}\; \texttt{%
% \href{mailto:`r email`}%
% {`r email`}}\\[8mm]
% \textbf{Project Leads: `r Project_Lead`}\\[8mm]
% \textbf{Project Leads: `r project_lead`}\\[8mm]
% \today
% \end{FlushRight}
Expand All @@ -109,7 +110,7 @@ subtitle: "Descriptive title for report \n Report for `r Pro_Num`"
author:
- Adam Sparks
- "Email: `r email`"
- "Project Leads: `r Project_Lead`"
- "Project Leads: `r project_lead`"
---

```{r}
Expand Down
88 changes: 43 additions & 45 deletions docs/demos/template-short-report.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,19 @@
title: "`r paste('Progress report for project', params[['project-number']])`"
subtitle: "Subtitle here"
params:
uni: CU
pri_bio: Your.Name
project-number: ABC1234-567XYZ
author:
- Author 1
- Author 2
date: "`r format(Sys.time(), '%d %B, %Y')`"
email: [email protected]
version-number: 1.0.0

# Style options (Page/font size, Table of Contents, Section numbers, ..)
fontsize: 12pt
papersize: a4
toc: no
number-sections: no
sans-serif: yes
links-as-footnotes: no

# Bibliography options
bibliography: references.bib
csl: assets/biometrics.csl
link-citations: true

# LaTeX pdflatex options
header-includes:
- \usepackage{lipsum}
output:
bookdown::pdf_document2:
keep_tex: yes
latex_engine: pdflatex
template: assets/AAGI_markdown.tex
format:
aagi-pdf+short+report: default
---

```{r}
#| include: false
library(rmarkdown)
knitr::opts_chunk$set(
fig.path = "figure/Rplots-",
fig.align = "center",
fig.show = "hold",
comment = NA,
background = "white",
highlight = FALSE,
size = "small",
prompt = TRUE
)
# library(rmarkdown)
# This is probably necessary on Linux (with Proxima Nova and Cairo
# installed). We may need something else on Mac.
Expand Down Expand Up @@ -85,6 +52,30 @@ library(AAGIThemes)
library(AAGIPalettes)
```

```{r}
#| include: false
#| label: config-for-title
if(params$uni == "CU"){
project_lead = "Curtin University -- Prof Mark Gibberd, Dr Julia Easton, Prof Adam Sparks"
email = "[email protected]"
} else if(params$uni == "UA"){
project_lead = "University of Adelaide -- Dr Julian Taylor, Dr Olena Kravchuck"
email = paste(params$pri_bio, "adelaide.edu.au", sep = "")
} else {
project_lead = "University of Queensland -- Prof Scott Chapman, Emertius Prof Kaye Basford"
email = paste(params$pri_bio, "@uq.edu.au", sep = "")
}
```

---
author:
- "`r params$pri_bio`"
- Author 2
- "Project Lead: `r project_lead`"
email: "`r email`"
---

# Section 1

Report text goes here. This template is designed for smaller ("one-page") AAGI
Expand All @@ -93,11 +84,10 @@ reports. The AAGI logo and partners footer appear only on this first page.
You can colour text/tables/etc using the various AAGI palette colours. Use
`\textcolor{aagiteal}{...}` for \textcolor{aagiteal}{AAGI Teal}, or
`\textcolor{aagibrightgreen}{...}` for
\textcolor{aagibrightgreen}{AAGI Bright Green}, for instance. Table
\@ref(tab:aagipalette) shows the standard palette colours available for use.
\textcolor{aagibrightgreen}{AAGI Bright Green}, for instance. @tbl-aagipalette shows the standard palette colours available for use.

\begin{table}[h]
\caption{\label{tab:aagipalette}The AAGI palette colours.}
::: {#tbl-aagipalette}
```{=tex}
\centering
\begin{tabular}{|c | c | c | c |}
\hline
Expand All @@ -111,8 +101,13 @@ You can colour text/tables/etc using the various AAGI palette colours. Use
\cellcolor{aagiblack}\color{white}\texttt{aagiblack} & %
\cellcolor{aagigrey}\texttt{aagigrey} \\
\hline
\end{tabular}
\end{table}
\end{tabular}
```

The AAGI palette colours.

:::


## This is a subsection heading

Expand All @@ -128,7 +123,10 @@ this .Rmd file (but feel free to change the title to whatever you like).

Example R code, using the `AAGIThemes` package to produce
Figure \@ref(fig:example1).
```{r example1, fig.cap="Here is a plot.", fig.pos="h", fig.height=3}
```{r}
#| label: fig-example1
#| fig-cap: "Here is a plot."
#| fig-height: 3
plot_aagi(pressure)
```

Expand Down

0 comments on commit dcb58bb

Please sign in to comment.