Skip to content

Commit

Permalink
Add header and footer
Browse files Browse the repository at this point in the history
  • Loading branch information
perej1 committed Dec 10, 2023
1 parent 88ba75d commit 340e11a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.Rproj.user
.Rhistory
*.log
*.pdf
5 changes: 2 additions & 3 deletions R/stat_exercise.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ stat_exercise <- function(...) {
pkg_resource <- function(...) {
system.file(..., package = "perejrmd")
}

template <- pkg_resource("rmarkdown/templates/stat_exercise/resources/template.tex")

template <- pkg_resource(paste0("rmarkdown/templates/stat_exercise/",
"resources/template.tex"))
bookdown::pdf_document2(
latex_engine = "xelatex",
toc = FALSE,
Expand Down
20 changes: 19 additions & 1 deletion inst/rmarkdown/templates/stat_exercise/resources/template.tex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
\documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$lang$,$endif$$if(papersize)$$papersize$,$endif$$for(classoption)$$classoption$$sep$,$endfor$]{$documentclass$}
\documentclass[a4paper, 11pt]{article}
$if(fontfamily)$
\usepackage{$fontfamily$}
$else$
Expand Down Expand Up @@ -150,6 +150,24 @@
\setlength{\droptitle}{-2em}
$endif$

\usepackage{fancyhdr} % For creating header
\usepackage{lastpage} % For page count

% Create header
\pagestyle{fancy}
\setlength{\headheight}{35.10004pt}
\fancypagestyle{plain}{\pagestyle{fancy}}
\fancyhead[L]{$course-name$ \\
$department$ \\
$university$}
\fancyhead[R]{$lecturer$ / $assistant$ \\
Fall 2023 \\
\textbf{$exercise-name$}}

% Create footer
\fancyfoot[R]{\thepage\ / \pageref{LastPage}}
\fancyfoot[C]{}

\title{
\noindent
\large\textbf{$title$} \hfill \textbf{$first-name$ $last-name$} \\
Expand Down
9 changes: 6 additions & 3 deletions inst/rmarkdown/templates/stat_exercise/skeleton/skeleton.Rmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
---
title: "Untitled"
course-name: Statistics Course
exercise-name: Exercise Set 0
university: Aalto University
department: Department of Mathematics and Systems Analysis
lecturer: M. Luennoitsija
assistant: M. Opettaja
first-name: FirstName
last-name: LastName
module: ModuleNumber
Expand All @@ -9,9 +15,6 @@ lab-date: XX/XX/XX
due-date: XX/XX/XX
TA: John Smith
output: perejrmd::stat_exercise
papersize: a4paper
fontsize: 11pt
documentclass: article
geometry: margin=2cm
---

Expand Down

0 comments on commit 340e11a

Please sign in to comment.