Skip to content

Commit

Permalink
fix merge-from-hell
Browse files Browse the repository at this point in the history
  • Loading branch information
friendly committed Aug 7, 2024
2 parents 0da8c9b + 9d9aa8f commit 8af69b0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 9 additions & 3 deletions R/Eqn.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@
#' @examples
#'
#' Eqn('e=mc^2')
#' Eqn(cat('e=mc^2')) # equivalent, but unnecessary
#' Eqn(cat('e=mc^2 \n')) # equivalent, but unnecessary
#'
#' # Equation numbers & labels
#' Eqn('e=mc^2', number = FALSE)
#' Eqn('e=mc^2', label = 'eqn:einstein')
#' Eqn("X=U \\lambda V", label='eqn:svd')
#'
#' # Multiple expressions
#' Eqn("e=mc^2", "X=U \\lambda V", label='eqn:svd')
#'
#' # expressions that use cat() within their calls
#' Eqn(symbolicMatrix("u", "n", "k", lhs = 'SVD'),
#' symbolicMatrix("\\lambda", "k", "k", diag=TRUE),
Expand Down Expand Up @@ -68,8 +71,11 @@ Eqn <- function(...,
is_char <- sapply(tmp, is.character)[-1L]
chartmp <- as.character(tmp)[-1L]
for(i in 1L:length(chartmp)){
if(is_char[i]) cat(chartmp[i])
else eval(parse(text = chartmp[i]))
if(is_char[i]){
if(i > 1L && is_char[i-1L]) cat("\n")
cat(chartmp[i])
if(i == length(chartmp)) cat("\n")
} else eval(parse(text = chartmp[i]))
}
cat(sprintf("\\end{%s}\n", wrap))
invisible(NULL)
Expand Down
3 changes: 3 additions & 0 deletions man/Eqn.Rd

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

0 comments on commit 8af69b0

Please sign in to comment.