diff --git a/.gitignore b/.gitignore index 5b6a06525..69e0fa1dd 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,11 @@ .Rhistory .RData .Ruserdata + +*.aux +*.bbl +*.blg +*.bcf +*.log +*.run.xml + diff --git a/.travis.yml b/.travis.yml index 3d65984b2..ef099405e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: r sudo: false +latex: false cache: packages env: diff --git a/R/latex.R b/R/latex.R index 7e729653d..f769916e4 100644 --- a/R/latex.R +++ b/R/latex.R @@ -21,8 +21,15 @@ #' @param file A LaTeX file path. #' @param engine A LaTeX engine (can be set in the global option #' \code{tinytex.engine}, e.g., \code{options(tinytex.engine = 'xelatex')}). -#' @param bib_engine A bibliography engine (can be set in the global option +#' @param bib_engine A bibliography engine, one of \code{'bibtex'} and +#' \code{'biber'} (can be set in the global option #' \code{tinytex.bib_engine}). +#' If missing, the engine is inferred from the contents of \code{file}: if +#' the file contains \verb{\addbibresource} then the engine is assumed to +#' be \code{'biber'} unless \verb{backend=biber} occurs in the optional argument +#' to \code{biblatex}, provided the package occurs on one line. Otherwise, +#' the engine is assumed to be \code{'bibtex'} if \verb{\bibliography} +#' is present in \code{file}. #' @param engine_args Command-line arguments to be passed to \code{engine} (can #' be set in the global option \code{tinytex.engine_args}, e.g., #' \code{options(tinytex.engine_args = '-shell-escape'}). @@ -57,7 +64,26 @@ latexmk = function( } } if (missing(max_times)) max_times = getOption('tinytex.compile.max_times', max_times) - if (missing(bib_engine)) bib_engine = getOption('tinytex.bib_engine', bib_engine) + if (missing(bib_engine)) { + if (is.null(getOption('tinytex.bib_engine'))) { + file_lines = sub('(?