Skip to content

Commit

Permalink
add vspace and metric (see #59)
Browse files Browse the repository at this point in the history
  • Loading branch information
philchalmers committed Aug 31, 2024
1 parent 7bf9602 commit 04d552c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
32 changes: 31 additions & 1 deletion R/Eqn.R
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,39 @@ Eqn <- function(...,
#'
#' \code{Eqn_newline()} emits a newline in an equation
#'
#' @param vspace includes extra vertical space. If not specified
#' only newline returns are included.
#' Is used in concert with \code{metric}
#' @param metric metric of the vertical space. Defaults to
#' 'ex', but can be 'pt', 'mm', 'cm', 'em', 'bp', 'dd',
#' 'pc', or 'in'
#' @rdname Eqn
#' @export
Eqn_newline <- function() ' \\\\ \n'
#'
#' @examples
#'
#' Eqn_newline()
#' Eqn_newline(vspace=1.5)
#' Eqn_newline(vspace=1, metric='cm')
#'
Eqn_newline <- function(vspace = 0, metric = 'ex'){
checkLaTeXMetric(metric)
ret <- if(vspace > 0)
sprintf(" \\\\[%s%s] \n", as.character(vspace), metric)
else ' \\\\ \n'
ret
}


checkLaTeXMetric <- function(metric){
valid <- c('em', 'pt', 'mm', 'cm', 'ex',
'bp', 'dd', 'pc', 'in')
ret <- metric %in% valid
if(!ret) stop('LaTeX metric is invalid')
invisible(ret)
}



#' Eqn_text Include literal string in equations
#'
Expand Down
15 changes: 14 additions & 1 deletion man/Eqn.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 04d552c

Please sign in to comment.