Skip to content

Commit

Permalink
Updated moderncv to use new package structure
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchelloharawild committed Oct 8, 2020
1 parent 9d3d042 commit f437463
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 29 deletions.
17 changes: 0 additions & 17 deletions R/formats.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,6 @@
#'
NULL

#' @rdname cv_formats
#'
#' @param theme The theme used for the template.
#'
#' @export
moderncv <- function(..., theme = c("casual", "classic", "oldstyle", "banking", "fancy"),
latex_engine = "pdflatex") {
theme <- match.arg(theme)
template <- system.file("rmarkdown", "templates", "moderncv",
"resources", "moderncv.tex",
package = "vitae"
)
copy_supporting_files("moderncv")
cv_document(..., pandoc_vars = list(theme = theme),
template = template, latex_engine = latex_engine)
}

#' @rdname cv_formats
#'
#' @export
Expand Down
44 changes: 44 additions & 0 deletions R/moderncv.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#' @rdname cv_formats
#'
#' @param theme The theme used for the template.
#'
#' @export
moderncv <- function(..., theme = c("casual", "classic", "oldstyle", "banking", "fancy"),
latex_engine = "pdflatex") {
theme <- match.arg(theme)
template <- system.file("rmarkdown", "templates", "moderncv",
"resources", "moderncv.tex",
package = "vitae"
)
set_entry_formats(moderncv_cv_entries)
copy_supporting_files("moderncv")
cv_document(..., pandoc_vars = list(theme = theme),
template = template, latex_engine = latex_engine)
}

moderncv_cv_entries <- new_entry_formats(
brief = function(what, when, with){
paste(
c(
"\\nopagebreak",
glue_alt("\t\\cvitem{<<when>>}{<<what>>. <<with>>}")
),
collapse = "\n"
)
},
detailed = function(what, when, with, where, why){
why <- lapply(why, function(x) {
if(length(x) == 0) return("\\empty")
paste(c(
"\\begin{itemize}%",
paste0("\\item ", x, "%"),
"\\end{itemize}"
), collapse = "\n")
})

paste(c(
"\\nopagebreak",
glue_alt("\t\\cventry{<<when>>}{<<what>>}{<<with>>}{<<where>>}{}{<<why>>}")
), collapse = "\n")
}
)
12 changes: 0 additions & 12 deletions inst/rmarkdown/templates/moderncv/resources/moderncv.tex
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,6 @@
\quote{$aboutme$}
$endif$

% Templates for detailed entries
% Arguments: what when with where why
\usepackage{etoolbox}
\def\detaileditem#1#2#3#4#5{
\cventry{#2}{#1}{#3}{#4}{}{{\ifx#5\empty\else{\begin{itemize}#5\end{itemize}}\fi}}}
\def\detailedsection#1{\nopagebreak#1}

% Templates for brief entries
% Arguments: what when with
\def\briefitem#1#2#3{\cvitem{#2}{#1. #3}}
\def\briefsection#1{\nopagebreak#1}

%----------------------------------------------------------------------------------
% content
%----------------------------------------------------------------------------------
Expand Down

0 comments on commit f437463

Please sign in to comment.