diff --git a/.gitignore b/.gitignore index fcbe7509f..b6aded686 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ reference inst/doc .vscode +/.luarc.json diff --git a/DESCRIPTION b/DESCRIPTION index 44bb14857..35cdc80db 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -79,7 +79,11 @@ Authors@R: c( person("Dmytro", "Perepolkin", , "dperepolkin@gmail.com", role = "ctb", comment = c(ORCID = "0000-0001-8558-6183", github = "dmi3kno")), person("Tom", "Palmer", , "remlapmot@hotmail.com", role = "ctb", - comment = c(ORCID = "0000-0003-4655-4511", github = "remlapmot")) + comment = c(ORCID = "0000-0003-4655-4511", github = "remlapmot")), + person("Christopher T.", "Kenny", , "christopherkenny@fas.harvard.edu", role = "ctb", + comment = c(ORCID = "0000-0002-9386-6860", github = "christopherkenny")), + person("Shiro", "Kuriwaki", , "shirokuriwaki@gmail.com", role = "ctb", + comment = c(ORCID = "0000-0002-5687-2647", github = "kuriwaki")) ) Description: A suite of custom R Markdown formats and templates for authoring journal articles and conference submissions. diff --git a/NAMESPACE b/NAMESPACE index 8929ca591..e2739c8ca 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -41,6 +41,7 @@ export(rjournal_article) export(rsos_article) export(rss_article) export(sage_article) +export(science_article) export(sim_article) export(springer_article) export(string_to_table) diff --git a/NEWS.md b/NEWS.md index f3c9b6c9e..f1f423fe6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -139,6 +139,8 @@ - New `isba_article()` template for submissions to Bayesian Analysis journal (thanks, @dmi3kno, #461). +- New `science_article()` template for submissions to Science journal (thanks, @christopherkenny, @kuriwaki, #486). + ## MINOR CHANGES - Update Copernicus Publications template to version 6.6 from 2022-01-18 (@RLumSK, #463, #464). diff --git a/R/science_article.R b/R/science_article.R new file mode 100644 index 000000000..0438f14d6 --- /dev/null +++ b/R/science_article.R @@ -0,0 +1,492 @@ +#' Science Journal Format +#' +#' Format for creating submissions to Science. Based on the Science +#' [class](https://www.sciencemag.org/site/feature/contribinfo/prep/TeX_help/#downloads). +#' Note that this template only works for `bibtext` with `natbib` for citations. +#' +#' @inheritParams rmarkdown::pdf_document +#' @param ... Additional arguments to [rmarkdown::pdf_document()] +#' @param move_figures set to `TRUE` to move figures to end. Default is `TRUE`. Only +#' works when `draft == TRUE`. +#' @param move_tables set to `TRUE` to move tables to end. Default is `TRUE`. Only +#' works when `draft == TRUE`. +#' @param draft set to `TRUE` for the draft version or `FALSE` for a +#' final submission version. `TRUE` moves the supplemental +#' materials to its own file. +#' +#' @md +#' @export +science_article <- function(..., keep_tex = TRUE, move_figures = TRUE, + move_tables = TRUE, number_sections = FALSE, + draft = TRUE, pandoc_args = NULL) { + + if (!number_sections) { + pandoc_args <- c( + pandoc_args, + "--lua-filter", pkg_file("rmarkdown", "lua", "unnumber-sections.lua") + ) + } + + base <- pdf_document_format( + 'science', + keep_tex = keep_tex, number_sections = number_sections, + pandoc_args = pandoc_args, ... + ) + + # Build from the rjournal_article post processing + base$pandoc$to <- 'latex' + base$pandoc$ext <- '.tex' + + # Process authors; + # if version == 'draft' move figures/tables to the end; Remove Section Numbers + # if version == 'final', save each figure/table in a separate PDF & + # Also the Supplementary materials must be in a separate PDF + base$post_processor <- function(metadata, utf8_input, output_file, clean, verbose) { + filename <- basename(output_file) + # underscores in the filename will be problematic in \input{filename}; + # pandoc will escape underscores but it should not, i.e., should be + # \input{foo_bar} instead of \input{foo\_bar} + if (filename != (filename2 <- gsub('_', '-', filename))) { + file.rename(filename, filename2) + filename <- filename2 + } + + # post process TEX file + temp_tex <- xfun::read_utf8(filename) + temp_tex <- post_process_authors_and(temp_tex) + if (isTRUE(draft)) { + if (move_figures) { + temp_tex <- relocate_figures(temp_tex) + } + if (move_tables) { + temp_tex <- relocate_tables(temp_tex) + } + } else { + temp_tex <- separate_appendix(output_file, temp_tex, number_sections) + + # Build Supplement + if (file.exists(paste0('supplement_', output_file))) { + tinytex::latexmk(paste0('supplement_', filename), + base$pandoc$latex_engine, + clean = clean + ) + } + } + + xfun::write_utf8(temp_tex, filename) + + tinytex::latexmk(filename, base$pandoc$latex_engine, + clean = clean, + bib_engine = 'bibtex' + ) + } + + base +} + +# Science Specific Helpers ---- +relocate_figures <- function(text) { + # locate where the figures are; check count + starts <- grep('\\\\begin\\{figure\\}', text) + ends <- grep('\\\\end\\{figure\\}', text) + if (length(starts) != length(ends)) { + warning("It appears that you have a figure that doesn't start and/or end properly", + 'Moving figures to end is cancelled.', + call. = FALSE + ) + return(text) + } + + # exit if no figures to move + if (length(starts) == 0) { + return(text) + } + + # check for appendix; subset; recheck count + appendix <- c(grep('\\\\appendix', text), grep('\052\\{\\(APPENDIX\\) Appendix\\}\\\\', text)) + if (length(appendix) > 0) { + appendix <- min(appendix) + starts <- starts[starts < appendix] + ends <- ends[ends < appendix] + if (length(starts) != length(ends)) { + warning('It appears there is a call to \\appendix within a figure environment.', + 'Moving figures to end is cancelled.', + call. = FALSE + ) + return(text) + } + } + + # Add notes to where things go. + for (i in seq_along(starts)) { + fig_marker <- paste('(Figure', i, 'goes about here.)') + text <- append(text, values = fig_marker, after = starts[i] - 1) + starts[seq_along(starts) >= i] <- starts[seq_along(starts) >= i] + 1L + } + + # update indices + starts <- grep('\\\\begin\\{figure\\}', text) + ends <- grep('\\\\end\\{figure\\}', text) + appendix <- c(grep('\\\\appendix', text), grep('\052\\{\\(APPENDIX\\) Appendix\\}\\\\', text)) + if (length(appendix) > 0) { + appendix <- min(appendix) + starts <- starts[starts < appendix] + ends <- ends[ends < appendix] + } + + # extract figures from tex; add guide to start + fig_index <- lapply(seq_along(starts), function(x) { + starts[x]:ends[x] + }) + fig_tex <- lapply(fig_index, function(x) { + text[x] + }) + + # Add a blank line after to use for injecting: + fig_tex <- lapply(fig_tex, function(x) { + c(x, '') + }) + + # subset + fig_index <- unlist(fig_index) + if (length(fig_index) > 0) { + text <- text[-unlist(fig_index)] + } + + # locate where the figures should go; check distance + start_enter <- grep('%%%begfigs---', text) + end_enter <- grep('%%%endfigs---', text) + if (end_enter - start_enter != 2) { + warning('Text may not contain `%%%begfigs---` or `%%%endfigs---`.', + 'Moving figures to end is cancelled.', + call. = FALSE + ) + return(text) + } + + # template requires LaTeX placeins for this: + # ensures figures start on a new page and can't jump up in space + text <- append(text, '\\FloatBarrier', after = start_enter - 1) + text <- append(text, '\\newpage', after = start_enter) + start_enter <- start_enter + 2L + + # inject + for (i in seq_along(fig_tex)) { + text <- append(text, fig_tex[[i]], after = start_enter) + start_enter <- start_enter + length(fig_tex[[i]]) + } + + # now process appendix ---- + main_enter <- grep('%%%begfigs---', text) + start_enter <- grep('%%%begappxfigs---', text) + end_enter <- grep('%%%endappxfigs---', text) + if (end_enter - start_enter != 2) { + warning('Text may not contain `%%%begappxfigs---` or `%%%endappxfigs---`.', + 'Moving figures to end is cancelled.', + call. = FALSE + ) + return(text) + } + + starts <- grep('\\\\begin\\{figure\\}', text) + ends <- grep('\\\\end\\{figure\\}', text) + + if (length(appendix) > 0) { + starts <- starts[starts < main_enter] + ends <- ends[ends < main_enter] + } + + # extract figures from tex; add guide to start + fig_index <- lapply(seq_along(starts), function(x) { + starts[x]:ends[x] + }) + fig_tex <- lapply(fig_index, function(x) { + text[x] + }) + + # Add a blank line after to use for injecting: + fig_tex <- lapply(fig_tex, function(x) { + c(x, '') + }) + + # subset + fig_index <- unlist(fig_index) + if (length(fig_index) > 0) { + text <- text[-unlist(fig_index)] + } + + # relocate reference + start_enter <- grep('%%%begappxfigs---', text) + + # ensures figures start on a new page and can't jump up in space + text <- append(text, '\\FloatBarrier', after = start_enter - 1) + text <- append(text, '\\newpage', after = start_enter) + start_enter <- start_enter + 2L + + # inject + for (i in seq_along(fig_tex)) { + text <- append(text, fig_tex[[i]], after = start_enter) + start_enter <- start_enter + length(fig_tex[[i]]) + } + + text +} + +relocate_tables <- function(text) { + # locate where the tables are; check count + starts <- grep('\\\\begin\\{table\\}', text) + ends <- grep('\\\\end\\{table\\}', text) + if (length(starts) != length(ends)) { + warning("It appears that you have a table that doesn't start properly or end properly", + 'Moving tables to end is cancelled.', + call. = FALSE + ) + return(text) + } + + # exit if no tables to move + if (length(starts) == 0) { + return(text) + } + + # check for appendix; subset; recheck count + appendix <- c(grep('\\\\appendix', text), grep('\052\\{\\(APPENDIX\\) Appendix\\}\\\\', text)) + if (length(appendix) > 0) { + appendix <- min(appendix) + starts <- starts[starts < appendix] + ends <- ends[ends < appendix] + if (length(starts) != length(ends)) { + warning('It appears there is a call to \\appendix within a table environment.', + 'Moving tables to end is cancelled.', + call. = FALSE + ) + return(text) + } + } + + # Add notes to where things go. + for (i in seq_along(starts)) { + tab_marker <- paste('(Table', i, 'goes about here.)') + text <- append(text, values = tab_marker, after = starts[i] - 1) + starts[seq_along(starts) >= i] <- starts[seq_along(starts) >= i] + 1L + } + + # update indices + starts <- grep('\\\\begin\\{table\\}', text) + ends <- grep('\\\\end\\{table\\}', text) + appendix <- c(grep('\\\\appendix', text), grep('\052\\{\\(APPENDIX\\) Appendix\\}\\\\', text)) + if (length(appendix) > 0) { + appendix <- min(appendix) + starts <- starts[starts < appendix] + ends <- ends[ends < appendix] + } + + # extract tables from tex; add guide to start + tab_index <- lapply(seq_along(starts), function(x) { + starts[x]:ends[x] + }) + tab_tex <- lapply(tab_index, function(x) { + text[x] + }) + + # Add a blank line after to use for injecting: + tab_tex <- lapply(tab_tex, function(x) { + c(x, '') + }) + + # subset + tab_index <- unlist(tab_index) + if (length(tab_index) > 0) { + text <- text[-tab_index] + } + + + # locate where the tables should go; check distance + start_enter <- grep('%%%begtabs---', text) + end_enter <- grep('%%%endtabs---', text) + if (end_enter - start_enter != 2) { + warning('Text may not contain `%%%begtabs---` or `%%%endtabs---`.', + 'Moving tables to end is cancelled.', + call. = FALSE + ) + return(text) + } + + # template requires LaTeX placeins for this: + # ensures tables start on a new page and can't jump up in space + text <- append(text, '\\FloatBarrier', after = start_enter - 1) + text <- append(text, '\\newpage', after = start_enter) + start_enter <- start_enter + 2L + + # inject + for (i in seq_along(tab_tex)) { + text <- append(text, tab_tex[[i]], after = start_enter) + start_enter <- start_enter + length(tab_tex[[i]]) + } + + # now process appendix ---- + main_enter <- grep('%%%begtabs---', text) + start_enter <- grep('%%%begappxtabs---', text) + end_enter <- grep('%%%endappxtabs---', text) + if (end_enter - start_enter != 2) { + warning('Text may not contain `%%%begappxtabs---` or `%%%endappxtabs---`.', + 'Moving tables to end is cancelled.', + call. = FALSE + ) + return(text) + } + + starts <- grep('\\\\begin\\{table\\}', text) + ends <- grep('\\\\end\\{table\\}', text) + + if (length(appendix) > 0) { + starts <- starts[starts < main_enter] + ends <- ends[ends < main_enter] + } + + # extract tables from tex; add guide to start + tab_index <- lapply(seq_along(starts), function(x) { + starts[x]:ends[x] + }) + tab_tex <- lapply(tab_index, function(x) { + text[x] + }) + + # Add a blank line after to use for injecting: + tab_tex <- lapply(tab_tex, function(x) { + c(x, '') + }) + + # subset + tab_index <- unlist(tab_index) + if (length(tab_index) > 0) { + text <- text[-tab_index] + } + + # relocate reference + start_enter <- grep('%%%begappxtabs---', text) + + # ensures tables start on a new page and can't jump up in space + text <- append(text, '\\FloatBarrier', after = start_enter - 1) + text <- append(text, '\\newpage', after = start_enter) + start_enter <- start_enter + 2L + + # inject + for (i in seq_along(tab_tex)) { + text <- append(text, tab_tex[[i]], after = start_enter) + start_enter <- start_enter + length(tab_tex[[i]]) + } + + text +} + +separate_appendix <- function(output_file, text, number_sections) { + # locate key points + begin_doc <- grep('\\\\begin\\{document\\}', text) + biblio <- grep('\\\\bibliography\\{references.bib\\}', text) + appendix <- c(grep('\\\\appendix', text), grep('\052\\{\\(APPENDIX\\) Appendix\\}\\\\', text)) + end_doc <- grep('\\\\end\\{document\\}', text) + + if (length(appendix) == 0) { + return(text) + } + # separate + main_text <- text[c(1:(appendix - 2), biblio:end_doc)] + appx_text <- text[c(1:(begin_doc), (appendix - 1):(biblio - 1), end_doc)] + + fix_appx_title <- c( + grep('\\\\appendix', appx_text), + grep('\052\\{\\(APPENDIX\\) Appendix\\}\\\\', appx_text) + ) + + appx_text[(fix_appx_title - 1):(fix_appx_title + 1)] <- c( + '\\maketitle', '\\section*{Supplementary Text}', + '\\renewcommand{\\thesection}{S\\arabic{section}}' + ) + + appx_text <- remove_authors_affiliations(appx_text) + + # write supplement + xfun::write_utf8(appx_text, con = paste0('supplement_', output_file)) + + # return main text for further processing + main_text +} + + + +post_process_authors_and <- function(text) { + i1 <- grep('^\\\\author\\{', text) + if (length(i1) == 0L) { + return(text) + } + if (length(i1) > 1L) { + warning("There should be only one instance of '\\author{}' in the tex file.", + 'Post-processing \\author{} is cancelled.', + call. = FALSE + ) + return(text) + } + + i2 <- grep('\\\\\\\\$', text) + i2 <- i2[i2 >= i1][1] + i <- (i1 + 1):(i2 - 1) + + # locate commas + text[i2 - 1] <- sub(pattern = ',', '', text[i2 - 1]) + + # if multiple authors, add and + if (length(i) > 1) { + text[i2 - 1] <- paste('and', text[i2 - 1]) + } + + # if 3 or less, no need to break lines + if (length(i) <= 3) { + return(text) + } + + # otherwise need to clean up spacing + add_spaces <- i[seq(1, length(i), by = 3)[-1] - 1] + for (i in seq_along(add_spaces)) { + text[add_spaces[i]] <- paste0(text[add_spaces[i]], '\\\\') + } + + text +} + +remove_authors_affiliations <- function(text) { + i1 <- grep('^\\\\author\\{', text) + if (length(i1) == 0L) { + return(text) + } + if (length(i1) > 1L) { + warning("There should be only one instance of '\\author{}' in the tex file.", + 'Post-processing \\author{} is cancelled.', + call. = FALSE + ) + return(text) + } + + i2 <- which(text == '}') + i2 <- i2[i2 >= i1][1] + + corr_aut <- grep('\\\\textsuperscript\\{\\*\\}', text) + + text[i1:(corr_aut[2] - 1)] <- gsub('\\\\textsuperscript\\{(.*)\\}', '', text[i1:(corr_aut[2] - 1)]) + text[i1:(corr_aut[2] - 1)] <- gsub('\\\\normalsize\\{.*', '', text[i1:(corr_aut[2] - 1)]) + + text[corr_aut[1]] <- paste0(text[corr_aut[1]], '\\textsuperscript{*}') + + text[i1:(corr_aut[2] - 1)] <- ifelse(text[i1:(corr_aut[2] - 1)] == '\\\\', '', + text[i1:(corr_aut[2] - 1)] + ) + text[corr_aut[2]] <- paste0('\\\\', text[corr_aut[2]]) + + # remove newly created empty lines + empty_lines <- which(text == '') + empty_lines <- empty_lines[empty_lines %in% i1:(corr_aut[2] - 1)] + + text <- text[-empty_lines] + + text +} diff --git a/README.Rmd b/README.Rmd index 531ba10c3..1f5c21ddb 100644 --- a/README.Rmd +++ b/README.Rmd @@ -87,51 +87,52 @@ output format and all the assets required by this format. Currently included templates and their contributors are the following: -| Journal | Contributors | Pull request | Output format | -|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------| -| [ACM: Association for Computings Machinery](https://www.acm.org/publications/about-publications) | [\@ramnathv](https://github.com/ramnathv) | [#8](https://github.com/rstudio/rticles/pull/8) | `acm_article()` | -| ACS `https://pubs.acs.org` | [\@yufree](https://github.com/yufree) | [#15](https://github.com/rstudio/rticles/pull/15) | `acs_article()` | -| [AEA: American Economic Association](https://www.aeaweb.org/journals/policies/templates) | [\@sboysel](https://github.com/sboysel) | [#86](https://github.com/rstudio/rticles/pull/86) | `aea_articles()` | -| AGU `https://agupubs.onlinelibrary.wiley.com/` | [\@eliocamp](https://github.com/eliocamp) | [#199](https://github.com/rstudio/rticles/pull/199) | `agu_article()` | -| [AJS: Austrian Journal of Statistics](https://www.ajs.or.at) | [\@matthias-da](https://github.com/matthias-da) | [#437](https://github.com/rstudio/rticles/pull/437) | `ajs_article()` | -| [AMS: American Meteorological Society](https://www.ametsoc.org/) | [\@yufree](https://github.com/yufree) | [#96](https://github.com/rstudio/rticles/pull/96) | `ams_article()` | -| ASA: American Statistical Association `https://www.amstat.org/` | | [#111](https://github.com/rstudio/rticles/pull/111) | `asa_article()` | -| [arXiv](https://arxiv.org/) pre-prints based on George Kour's template | [\@alexpghayes](https://github.com) | [#236](https://github.com/rstudio/rticles/pull/236) | `arxiv_article()` | -| [Bioinformatics](https://academic.oup.com/bioinformatics) | [\@ShixiangWang](https://github.com/ShixiangWang) | [#297](https://github.com/rstudio/rticles/pull/297) | `bioinformatics_article()` | -| [Biometrics](https://biometrics.biometricsociety.org) | [\@daltonhance](https://github.com/daltonhance) | [#170](https://github.com/rstudio/rticles/pull/170) | `biometrics_article()` | -| Bulletin de l'AMQ (`https://www.amq.math.ca/bulletin/`) | [\@desautm](https://github.com/desautm) | [#145](https://github.com/rstudio/rticles/pull/145) | `amq_article()` | -| [Copernicus Publications](https://publications.copernicus.org) | [\@nuest](https://github.com/nuest), [\@RLumSK](https://github.com/RLumSK) | [#172](https://github.com/rstudio/rticles/pull/172), [#342](https://github.com/rstudio/rticles/pull/342) | `copernicus_article()` | -| [CTeX](https://ctan.org/pkg/ctex) | | | `ctex()` | -| [Elsevier](https://www.elsevier.com) | [\@cboettig](https://github.com/cboettig), [\@robjhyndman](https://github.com/robjhyndman) | [#27](https://github.com/rstudio/rticles/pull/27), [#467](https://github.com/rstudio/rticles/pull/467) | `elsevier_article()` | -| [Frontiers](https://www.frontiersin.org/) | [\@muschellij2](https://github.com/muschellij2) | [#211](https://github.com/rstudio/rticles/pull/211) | `frontiers_article()` | -| [Glossa](https://www.glossa-journal.org) | [\@stefanocoretta](https://github.com/stefanocoretta) | [#361](https://github.com/rstudio/rticles/pull/361) | `glossa_article()` | -| [IEEE Transaction](https://www.ieee.org/publications_standards/publications/authors/author_templates.html) | [\@Emaasit](https://github.com/Emaasit), [\@espinielli](https://github.com/espinielli), [\@nathanweeks](https://github.com/nathanweeks), [\@DunLug](https://github.com/DunLug) | [#97](https://github.com/rstudio/rticles/pull/97), [#169](https://github.com/rstudio/rticles/pull/169), [#227](https://github.com/rstudio/rticles/pull/227), [#263](https://github.com/rstudio/rticles/pull/263), [#264](https://github.com/rstudio/rticles/pull/264), [#265](https://github.com/rstudio/rticles/pull/265) | `ieee_article()` | -| [IMS: Institute of Mathematical Statistics](https://imstat.org/) [AoAS: Annals of Applied Statistics](https://imstat.org/journals-and-publications/annals-of-applied-statistics/) | [\@auzaheta](https://github.com/auzaheta) | [#372](https://github.com/rstudio/rticles/pull/372) | `ims_article()` | -| [INFORMS: Institute for Operations Research and the Management Sciences](https://www.informs.org/) | [\@robjhyndman](https://github.com/robjhyndman) | [#460](https://github.com/rstudio/rticles/pull/460) | `informs_article()` | -| [ISBA: International Society for Bayesian Analysis](https://bayesian.org/) | [\@dmi3nko](https://github.com/dmi3kno) | [#461](https://github.com/rstudio/rticles/pull/461) | `isba_article()` | -| IOP: Institute of Physics (`https://iopscience.iop.org`) | [\@robjhyndman](https://github.com/robjhyndman) | [#462](https://github.com/rstudio/rticles/pull/462) | `iop_article()` | -| [JASA: Journal of the Acoustical Society of America](https://pubs.aip.org/asa/jasa) | [\@stefanocoretta](https://github.com/stefanocoretta) | [#364](https://github.com/rstudio/rticles/pull/364) | `jasa_article()` | -| [Journal of Educational Data Mining](https://jedm.educationaldatamining.org/index.php/JEDM/about/submissions) journal submissions | [\@jooyoungseo](https://github.com/jooyoungseo) | [#251](https://github.com/rstudio/rticles/pull/251) | `jedm_article()` | -| [JOSS: Journal of Open Source Software](https://joss.theoj.org/) [JOSE: Journal of Open Source Education](https://jose.theoj.org/) | [\@noamross](https://github.com/noamross) | [#229](https://github.com/rstudio/rticles/pull/229) | `joss_article()` | -| [JSS: Journal of Statistical Software](https://www.jstatsoft.org/index) | | | `jss_article()` | -| [LIPIcs](https://www.dagstuhl.de/en/publishing/series/details/lipics) | [\@nuest](https://github.com/nuest) | [#288](https://github.com/rstudio/rticles/pull/288) | `lipics_article()` | -| [MDPI](https://www.mdpi.com) | [\@dleutnant](https://github.com/dleutnant), [\@mps9506](https://github.com/mps9506) | [#147](https://github.com/rstudio/rticles/pull/147), [#515](https://github.com/rstudio/rticles/pull/515) | `mdpi_article()` | -| [MNRAS: Monthly Notices of the Royal Astronomical Society](https://academic.oup.com/mnras) | [\@oleskiewicz](https://github.com/oleskiewicz) | [#175](https://github.com/rstudio/rticles/pull/175) | `mnras_article()` | -| [OUP: Oxford University Press](https://academic.oup.com/pages/authoring/journals/preparing_your_manuscript) | [\@dmkaplan](https://github.com/dmkaplan) | [#284](https://github.com/rstudio/rticles/pull/284) | `oup_articles()` | -| [PeerJ: Journal of Life and Environmental Sciences](https://peerj.com) | [\@zkamvar](https://github.com/zkamvar) | [#127](https://github.com/rstudio/rticles/pull/127) | `peerj_article()` | -| [PiHPh: Papers in Historical Phonology](http://journals.ed.ac.uk/pihph/about/submissions) | [\@stefanocoretta](https://github.com/stefanocoretta) | [#362](https://github.com/rstudio/rticles/pull/362) | `pihph_article()` | -| [PLOS](https://plos.org/#journals) | [\@sjmgarnier](https://github.com/sjmgarnier) | [#12](https://github.com/rstudio/rticles/pull/12) | `plos_article()` | -| PNAS: Proceedings of the National Academy of Sciences (`https://www.pnas.org/`) | [\@cboettig](https://github.com/cboettig) | [#72](https://github.com/rstudio/rticles/pull/72) | `pnas_article()` | -| RSOS: Royal Society Open Science `https://www.royalsocietypublishing.org/journal/rsos` | [\@ThierryO](https://github.com/ThierryO) | [#135](https://github.com/rstudio/rticles/pull/135) | `rsos_article()` | -| [RSS: Royal Statistical Society](https://rss.org.uk/) | [\@carlganz](https://github.com/carlganz) | [#110](https://github.com/rstudio/rticles/pull/110) | `rss_article()` | -| [Sage](https://uk.sagepub.com/en-gb/eur/manuscript-submission-guidelines) | [\@oguzhanogreden](https://github.com/oguzhanogreden) | [#181](https://github.com/rstudio/rticles/pull/181) | `sage_article()` | -| [Springer](https://www.springernature.com/gp/authors/campaigns/latex-author-support) | [\@strakaps](https://github.com/strakaps) | [#164](https://github.com/rstudio/rticles/pull/164) | `springer_article()` | -| [Springer Lecture Notes in Computer Science (LCNS)](https://www.springer.com/gp/computer-science/lncs/conference-proceedings-guidelines) | [\@eliocamp](https://github.com/eliocamp/) | [#445](https://github.com/rstudio/rticles/issues/445) | `lncs_article()` | -| SIM: Statistics in Medicine `https://onlinelibrary.wiley.com/journal/10970258)` | [\@ellessenne](https://github.com/ellessenne) | [#231](https://github.com/rstudio/rticles/pull/231) | `sim_article()` | -| Taylor & Francis (`https://www.tandfonline.com/`) | [\@dleutnant](https://github.com/dleutnant) | [#218](https://github.com/rstudio/rticles/pull/218) | `tf_article()` | -| [The R Journal](https://journal.r-project.org/) | | | Use [rjtools](https://rjournal.github.io/rjtools/) package now. `rjournal_article()` is deprecated. | -| [TRB](https://trb.secure-platform.com/a/page/TRBPaperReview) | [\@gregmacfarlane](https://github.com/gregmacfarlane) | [#427](https://github.com/rstudio/rticles/pull/427) | `trb_article()` | -| [Wellcome Open Research](https://wellcomeopenresearch.org) | [\@arnold-c](https://github.com/arnold-c) | [#436](https://github.com/rstudio/rticles/pull/436) | `wellcomeor_article()` | +| Journal | Contributors | Pull request | Output format | +|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------| +| [ACM: Association for Computings Machinery](https://www.acm.org/publications/about-publications) | [\@ramnathv](https://github.com/ramnathv) | [#8](https://github.com/rstudio/rticles/pull/8) | `acm_article()` | +| [ACS](https://pubs.acs.org) | [\@yufree](https://github.com/yufree) | [#15](https://github.com/rstudio/rticles/pull/15) | `acs_article()` | +| [AEA: American Economic Association](https://www.aeaweb.org/journals/policies/templates) | [\@sboysel](https://github.com/sboysel) | [#86](https://github.com/rstudio/rticles/pull/86) | `aea_articles()` | +| [AGU](https://agupubs.onlinelibrary.wiley.com/) | [\@eliocamp](https://github.com/eliocamp) | [#199](https://github.com/rstudio/rticles/pull/199) | `agu_article()` | +| [AJS: Austrian Journal of Statistics](https://www.ajs.or.at) | [\@matthias-da](https://github.com/matthias-da) | [#437](https://github.com/rstudio/rticles/pull/437) | `ajs_article()` | +| [AMS: American Meteorological Society](https://www.ametsoc.org/) | [\@yufree](https://github.com/yufree) | [#96](https://github.com/rstudio/rticles/pull/96) | `ams_article()` | +| ASA: American Statistical Association `https://www.amstat.org/` | | [#111](https://github.com/rstudio/rticles/pull/111) | `asa_article()` | +| [arXiv](https://arxiv.org/) pre-prints based on George Kour's template | [\@alexpghayes](https://github.com) | [#236](https://github.com/rstudio/rticles/pull/236) | `arxiv_article()` | +| [Bioinformatics](https://academic.oup.com/bioinformatics) | [\@ShixiangWang](https://github.com/ShixiangWang) | [#297](https://github.com/rstudio/rticles/pull/297) | `bioinformatics_article()` | +| [Biometrics](https://biometrics.biometricsociety.org) | [\@daltonhance](https://github.com/daltonhance) | [#170](https://github.com/rstudio/rticles/pull/170) | `biometrics_article()` | +| [Bulletin de l'AMQ](https://www.amq.math.ca/bulletin/) | [\@desautm](https://github.com/desautm) | [#145](https://github.com/rstudio/rticles/pull/145) | `amq_article()` | +| [Copernicus Publications](https://publications.copernicus.org) | [\@nuest](https://github.com/nuest), [\@RLumSK](https://github.com/RLumSK) | [#172](https://github.com/rstudio/rticles/pull/172), [#342](https://github.com/rstudio/rticles/pull/342) | `copernicus_article()` | +| [CTeX](https://ctan.org/pkg/ctex) | | | `ctex()` | +| [Elsevier](https://www.elsevier.com) | [\@cboettig](https://github.com/cboettig), [\@robjhyndman](https://github.com/robjhyndman) | [#27](https://github.com/rstudio/rticles/pull/27), [#467](https://github.com/rstudio/rticles/pull/467) | `elsevier_article()` | +| [Frontiers](https://www.frontiersin.org/) | [\@muschellij2](https://github.com/muschellij2) | [#211](https://github.com/rstudio/rticles/pull/211) | `frontiers_article()` | +| [Glossa](https://www.glossa-journal.org) | [\@stefanocoretta](https://github.com/stefanocoretta) | [#361](https://github.com/rstudio/rticles/pull/361) | `glossa_article()` | +| [IEEE Transaction](http://www.ieee.org/publications_standards/publications/authors/author_templates.html) | [\@Emaasit](https://github.com/Emaasit), [\@espinielli](https://github.com/espinielli), [\@nathanweeks](https://github.com/nathanweeks), [\@DunLug](https://github.com/DunLug) | [#97](https://github.com/rstudio/rticles/pull/97), [#169](https://github.com/rstudio/rticles/pull/169), [#227](https://github.com/rstudio/rticles/pull/227), [#263](https://github.com/rstudio/rticles/pull/263), [#264](https://github.com/rstudio/rticles/pull/264), [#265](https://github.com/rstudio/rticles/pull/265) | `ieee_article()` | +| [IMS: Institute of Mathematical Statistics](https://imstat.org/) [AoAS: Annals of Applied Statistics](https://imstat.org/journals-and-publications/annals-of-applied-statistics/) | [\@auzaheta](https://github.com/auzaheta) | [#372](https://github.com/rstudio/rticles/pull/372) | `ims_article()` | +| [INFORMS: Institute for Operations Research and the Management Sciences](https://www.informs.org/) | [\@robjhyndman](https://github.com/robjhyndman) | [#460](https://github.com/rstudio/rticles/pull/460) | `informs_article()` | +| [ISBA: International Society for Bayesian Analysis](https://bayesian.org/) | [\@dmi3nko](https://github.com/dmi3kno) | [#461](https://github.com/rstudio/rticles/pull/461) | `isba_article()` | +| IOP: Institute of Physics (`https://iopscience.iop.org`) | [\@robjhyndman](https://github.com/robjhyndman) | [#462](https://github.com/rstudio/rticles/pull/462) | `iop_article()` | +| [JASA: Journal of the Acoustical Society of America](https://asa.scitation.org/journal/jas) | [\@stefanocoretta](https://github.com/stefanocoretta) | [#364](https://github.com/rstudio/rticles/pull/364) | `jasa_article()` | +| [Journal of Educational Data Mining](https://jedm.educationaldatamining.org/index.php/JEDM/about/submissions) journal submissions | [\@jooyoungseo](https://github.com/jooyoungseo) | [#251](https://github.com/rstudio/rticles/pull/251) | `jedm_article()` | +| [JOSS: Journal of Open Source Software](https://joss.theoj.org/) [JOSE: Journal of Open Source Education](https://jose.theoj.org/) | [\@noamross](https://github.com/noamross) | [#229](https://github.com/rstudio/rticles/pull/229) | `joss_article()` | +| [JSS: Journal of Statistical Software](https://www.jstatsoft.org/index) | | | `jss_article()` | +| [LIPIcs](https://www.dagstuhl.de/en/publications/lipics) | [\@nuest](https://github.com/nuest) | [#288](https://github.com/rstudio/rticles/pull/288) | `lipics_article()` | +| [MDPI](https://www.mdpi.com) | [\@dleutnant](https://github.com/dleutnant) | [#147](https://github.com/rstudio/rticles/pull/147) | `mdpi_article()` | +| [MNRAS: Monthly Notices of the Royal Astronomical Society](https://academic.oup.com/mnras) | [\@oleskiewicz](https://github.com/oleskiewicz) | [#175](https://github.com/rstudio/rticles/pull/175) | `mnras_article()` | +| [OUP: Oxford University Press](https://academic.oup.com/journals/pages/authors/preparing_your_manuscript) | [\@dmkaplan](https://github.com/dmkaplan) | [#284](https://github.com/rstudio/rticles/pull/284) | `oup_articles()` | +| [PeerJ: Journal of Life and Environmental Sciences](https://peerj.com) | [\@zkamvar](https://github.com/zkamvar) | [#127](https://github.com/rstudio/rticles/pull/127) | `peerj_article()` | +| [PiHPh: Papers in Historical Phonology](http://journals.ed.ac.uk/pihph/about/submissions) | [\@stefanocoretta](https://github.com/stefanocoretta) | [#362](https://github.com/rstudio/rticles/pull/362) | `pihph_article()` | +| [PLOS](https://plos.org/#journals) | [\@sjmgarnier](https://github.com/sjmgarnier) | [#12](https://github.com/rstudio/rticles/pull/12) | `plos_article()` | +| [PNAS: Proceedings of the National Academy of Sciences](https://www.pnas.org/) | [\@cboettig](https://github.com/cboettig) | [#72](https://github.com/rstudio/rticles/pull/72) | `pnas_article()` | +| [RSOS: Royal Society Open Science](https://www.royalsocietypublishing.org/journal/rsos) | [\@ThierryO](https://github.com/ThierryO) | [#135](https://github.com/rstudio/rticles/pull/135) | `rsos_article()` | +| [RSS: Royal Statistical Society](https://rss.org.uk/) | [\@carlganz](https://github.com/carlganz) | [#110](https://github.com/rstudio/rticles/pull/110) | `rss_article()` | +| [Sage](https://uk.sagepub.com/en-gb/eur/manuscript-submission-guidelines) | [\@oguzhanogreden](https://github.com/oguzhanogreden) | [#181](https://github.com/rstudio/rticles/pull/181) | `sage_article()` | +| [Science](https://www.science.org/) | [\@christopherkenny](https://github.com/christopherkenny), [\@kuriwaki](https://github.com/kuriwaki) | [#486](https://github.com/rstudio/rticles/pull/486) | `science_article()` | +| [Springer](https://www.springernature.com/gp/authors/campaigns/latex-author-support) \| [\@strakaps](https://github.com/strakaps) \| [#164](https://github.com/rstudio/rticles/pull/164) \| `springer_article()` \| | | | | +| [Springer Lecture Notes in Computer Science (LCNS)](https://www.springer.com/gp/computer-science/lncs/conference-proceedings-guidelines) \| [\@eliocamp](https://github.com/eliocamp/) \| [#445](https://github.com/rstudio/rticles/issues/445) \| `lncs_article()` \| | | | | +| [SIM: Statistics in Medicine](https://onlinelibrary.wiley.com/journal/10970258) \| [\@ellessenne](https://github.com/ellessenne) \| [#231](https://github.com/rstudio/rticles/pull/231) \| `sim_article()` \| | | | | +| [Taylor & Francis](https://www.tandfonline.com/) \| [\@dleutnant](https://github.com/dleutnant) \| [#218](https://github.com/rstudio/rticles/pull/218) \| `tf_article()` \| | | | | +| [The R Journal](https://journal.r-project.org/) \| \| \| `rjournal_article()` \| | | | | +| [TRB](https://trb.secure-platform.com/a/page/TRBPaperReview) \| [\@gregmacfarlane](https://github.com/gregmacfarlane) \| [#427](https://github.com/rstudio/rticles/pull/427) \| `trb_article()` \| | | | | +| [Wellcome Open Research](https://wellcomeopenresearch.org) \| [\@arnold-c](https://github.com/arnold-c) \| [#436](https://github.com/rstudio/rticles/pull/436) \| `wellcomeor_article()` \| | | | | You can also get the list of available journal names with `rticles::journals()`. @@ -154,9 +155,9 @@ and R code and its output can be seamlessly included using There are two main places to get help: 1. The [RStudio - community](https://forum.posit.co/tags/c/R-Markdown/10/rticles) - is a friendly place to ask any questions about **rticles**. Be sure - to use the `rticles` tag. + community](https://forum.posit.co/tags/c/R-Markdown/10/rticles) is a + friendly place to ask any questions about **rticles**. Be sure to + use the `rticles` tag. 2. [Stack Overflow](https://stackoverflow.com/questions/tagged/rticles) is a great source of answers to common **bookdown** questions. Use diff --git a/inst/rmarkdown/lua/unnumber-sections.lua b/inst/rmarkdown/lua/unnumber-sections.lua new file mode 100644 index 000000000..6f3ecceae --- /dev/null +++ b/inst/rmarkdown/lua/unnumber-sections.lua @@ -0,0 +1,11 @@ +--[[ + A Pandoc lua filter that unnumbers headers. + It inserts the unnumbered class to all headers without the class. + Author: Christopher T. Kenny +--]] +function Header(el) + if not el.classes:includes('unnumbered') then + el.classes:insert('unnumbered') + end + return el +end diff --git a/inst/rmarkdown/templates/science/resources/template.tex b/inst/rmarkdown/templates/science/resources/template.tex new file mode 100644 index 000000000..57db9de0f --- /dev/null +++ b/inst/rmarkdown/templates/science/resources/template.tex @@ -0,0 +1,223 @@ +% Use only LaTeX2e, calling the article.cls class and 12-point type. +\documentclass[$if(fontsize)$$fontsize$,$endif$]{article} + +% Users of the {thebibliography} environment or BibTeX should use the +% scicite.sty package, downloadable from *Science* at +% www.sciencemag.org/about/authors/prep/TeX_help/ . +% This package should properly format in-text +% reference calls and reference-list numbers. + +% Science template required packages +\usepackage{scicite} + +\usepackage{times} + +% add-ons for rticles +% based on arxiv.sty +\usepackage[utf8]{inputenc} % allow utf-8 input +\usepackage[T1]{fontenc} % use 8-bit T1 fonts +\usepackage[hidelinks]{hyperref} % hyperlinks +\usepackage{url} % simple URL typesetting +\usepackage{amsfonts} % blackboard math symbols +\usepackage{nicefrac} % compact symbols for 1/2, etc. +\usepackage{microtype} % microtypography +\usepackage{lipsum} +\usepackage{graphicx} + +% the basics +\usepackage{amsmath} +\usepackage{calc} +\usepackage{tabularx} + +% for figure adjustment +\usepackage{placeins} +\usepackage{flafter} + + +$if(highlighting-macros)$ +$highlighting-macros$ +$endif$ + + +% tightlist command for lists without linebreak +\providecommand{\tightlist}{% + \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} + +$if(tables)$ +% From pandoc table feature +\usepackage{longtable,booktabs,array} +$if(multirow)$ +\usepackage{multirow} +$endif$ +\usepackage{calc} % for calculating minipage widths +% Correct order of tables after \paragraph or \subparagraph +\usepackage{etoolbox} +\makeatletter +\patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{} +\makeatother +% Allow footnotes in longtable head/foot +\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}} +\makesavenoteenv{longtable} +$endif$ + +% Pandoc citation processing +$if(csl-refs)$ +\newlength{\csllabelwidth} +\setlength{\csllabelwidth}{3em} +\newlength{\cslhangindent} +\setlength{\cslhangindent}{1.5em} +% for Pandoc 2.8 to 2.10.1 +\newenvironment{cslreferences}% + {$if(csl-hanging-indent)$\setlength{\parindent}{0pt}% + \everypar{\setlength{\hangindent}{\cslhangindent}}\ignorespaces$endif$}% + {\par} +% For Pandoc 2.11+ +\newenvironment{CSLReferences}[2] % #1 hanging-ident, #2 entry spacing + {% don't indent paragraphs + \setlength{\parindent}{0pt} + % turn on hanging indent if param 1 is 1 + \ifodd #1 \everypar{\setlength{\hangindent}{\cslhangindent}}\ignorespaces\fi + % set entry spacing + \ifnum #2 > 0 + \setlength{\parskip}{#2\baselineskip} + \fi + }% + {} +\usepackage{calc} % for calculating minipage widths +\newcommand{\CSLBlock}[1]{#1\hfill\break} +\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{#1}} +\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1}\break} +\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1} +$endif$ + +$for(header-includes)$ +$header-includes$ +$endfor$ + + +% The following parameters seem to provide a reasonable page setup. + +\topmargin 0.0cm +\oddsidemargin 0.2cm +\textwidth 16cm +\textheight 21cm +\footskip 1.0cm + + +%The next command sets up an environment for the abstract to your paper. +\usepackage{setspace} + +\newenvironment{sciabstract}{% +\begin{quote} \singlespacing} +{\end{quote}} + +\renewcommand\refname{References and Notes} + +% Include your paper's title here + +\title{$title$} + + +% Place the author information here. Please hand-code the contact +% information and notecalls; do *not* use \footnote commands. Let the +% author contact information appear immediately below the author names +% as shown. We would also prefer that you don't change the type-size +% settings shown here. + + +\author{ +$for(authors)$ +$authors.name$,\textsuperscript{$authors.affiliation$}$if(authors.corresponding_author)$\textsuperscript{*}$endif$ +$endfor$\\ +\\ +$for(address)$ +\normalsize{\textsuperscript{$address.code$}$address.address$}\\ +$endfor$ +\\ +\textsuperscript{*}$corresponding_author$ +} + +% Include the date command, but leave its argument blank. + +\date{} + + + +%%%%%%%%%%%%%%%%% END OF PREAMBLE %%%%%%%%%%%%%%%% + + + +\begin{document} +$for(include-before)$ +$include-before$ + +$endfor$ +% Double-space the manuscript. + +\baselineskip24pt + +% Make the title. + +\maketitle + +% Place your abstract within the special {sciabstract} environment. + +\begin{sciabstract} +$abstract$ +\end{sciabstract} + +$body$ + +$if(bibliography)$ +\bibliography{$bibliography$} +\bibliographystyle{Science} +$endif$ + +$if(acknowledgements)$ +\section*{Acknowledgments} +$acknowledgements$ +$endif$ + + +$if(supplementary-materials)$ +\hypertarget{supplementary-materials}{% +\section{Supplementary materials}\label{supplementary-materials}} + +$for(supplementary-materials)$ +$supplementary-materials$ $sep$\\ +$endfor$ +$endif$ + +$for(include-after)$ +$include-after$ + +$endfor$ + +\renewcommand{\thetable}{\arabic{table}} +\renewcommand{\thefigure}{\arabic{figure}} +\setcounter{table}{0} +\setcounter{figure}{0} + +%%%begfigs--- + +%%%endfigs--- + +%%%begtabs--- + +%%%endtabs--- + +% Needs a bit of work on the \ref{} TODO before uncommenting +%\renewcommand{\thetable}{A\arabic{table}} +%\renewcommand{\thefigure}{A\arabic{figure}} +%\setcounter{table}{0} +%\setcounter{figure}{0} + +%%%begappxfigs--- + +%%%endappxfigs--- + +%%%begappxtabs--- + +%%%endappxtabs--- + +\end{document} diff --git a/inst/rmarkdown/templates/science/skeleton/Science.bst b/inst/rmarkdown/templates/science/skeleton/Science.bst new file mode 100644 index 000000000..49e54ddf9 --- /dev/null +++ b/inst/rmarkdown/templates/science/skeleton/Science.bst @@ -0,0 +1,1374 @@ +%% +%% This is file `Science.bst', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% merlin.mbs (with options: `head,,seq-no,nm-init,ed-au,nmlm,x5,m1,yr-par,xmth,jtit-x,thtit-a,trnum-it,vol-bf,vnum-x,volp-com,jpg-1,numser,jnm-x,pub-date,pre-pub,edby,edbyy,blk-com,blknt,in-x,pp,ed,abr,jabr,xand,etal-it,em-it,{}') +%% physjour.mbs (with options: `,seq-no,nm-init,ed-au,nmlm,x5,m1,yr-par,xmth,jtit-x,thtit-a,trnum-it,vol-bf,vnum-x,volp-com,jpg-1,numser,jnm-x,pub-date,pre-pub,edby,edbyy,blk-com,blknt,in-x,pp,ed,abr,jabr,xand,etal-it,em-it,{}') +%% merlin.mbs (with options: `tail,,seq-no,nm-init,ed-au,nmlm,x5,m1,yr-par,xmth,jtit-x,thtit-a,trnum-it,vol-bf,vnum-x,volp-com,jpg-1,numser,jnm-x,pub-date,pre-pub,edby,edbyy,blk-com,blknt,in-x,pp,ed,abr,jabr,xand,etal-it,em-it,{}') +%% ---------------------------------------- +%% *** Applicable to Science Journal references *** +%% +%% Copyright 1994-1999 Patrick W Daly + % =============================================================== + % IMPORTANT NOTICE: + % This bibliographic style (bst) file has been generated from one or + % more master bibliographic style (mbs) files, listed above. + % + % This generated file can be redistributed and/or modified under the terms + % of the LaTeX Project Public License Distributed from CTAN + % archives in directory macros/latex/base/lppl.txt; either + % version 1 of the License, or any later version. + % =============================================================== + % Name and version information of the main mbs file: + % \ProvidesFile{merlin.mbs}[1999/05/28 3.89 (PWD)] + % For use with BibTeX version 0.99a or later + %------------------------------------------------------------------- + % This bibliography style file is intended for texts in ENGLISH + % This is a numerical citation style, and as such is standard LaTeX. + % It requires no extra package to interface to the main text. + % The form of the \bibitem entries is + % \bibitem{key}... + % Usage of \cite is as follows: + % \cite{key} ==>> [#] + % \cite[chap. 2]{key} ==>> [#, chap. 2] + % where # is a number determined by the ordering in the reference list. + % The order in the reference list is that by which the works were originally + % cited in the text, or that in the database. + %--------------------------------------------------------------------- + +ENTRY + { address + author + booktitle + chapter + edition + editor + howpublished + institution + journal + key + month + note + number + organization + pages + publisher + school + series + title + type + volume + year + } + {} + { label } + +INTEGERS { output.state before.all mid.sentence after.sentence after.block } + +FUNCTION {init.state.consts} +{ #0 'before.all := + #1 'mid.sentence := + #2 'after.sentence := + #3 'after.block := +} + +STRINGS { s t } + +FUNCTION {output.nonnull} +{ 's := + output.state mid.sentence = + { ", " * write$ } + { output.state after.block = + { add.period$ write$ + newline$ + "\newblock " write$ + } + { output.state before.all = + 'write$ + { add.period$ " " * write$ } + if$ + } + if$ + mid.sentence 'output.state := + } + if$ + s +} + +FUNCTION {output} +{ duplicate$ empty$ + 'pop$ + 'output.nonnull + if$ +} + +FUNCTION {output.check} +{ 't := + duplicate$ empty$ + { pop$ "empty " t * " in " * cite$ * warning$ } + 'output.nonnull + if$ +} + +FUNCTION {fin.entry} +{ add.period$ + write$ + newline$ +} + +FUNCTION {new.block} +{ output.state before.all = + 'skip$ + { after.block 'output.state := } + if$ +} + +FUNCTION {new.sentence} +{ output.state after.block = + 'skip$ + { output.state before.all = + 'skip$ + { after.sentence 'output.state := } + if$ + } + if$ +} + +FUNCTION {add.blank} +{ " " * before.all 'output.state := +} + +FUNCTION {date.block} +{ + skip$ +} + +FUNCTION {not} +{ { #0 } + { #1 } + if$ +} + +FUNCTION {and} +{ 'skip$ + { pop$ #0 } + if$ +} + +FUNCTION {or} +{ { pop$ #1 } + 'skip$ + if$ +} + +FUNCTION {new.block.checka} +{ empty$ + 'skip$ + 'new.block + if$ +} + +FUNCTION {new.block.checkb} +{ empty$ + swap$ empty$ + and + 'skip$ + 'new.block + if$ +} + +FUNCTION {new.sentence.checka} +{ empty$ + 'skip$ + 'new.sentence + if$ +} + +FUNCTION {new.sentence.checkb} +{ empty$ + swap$ empty$ + and + 'skip$ + 'new.sentence + if$ +} + +FUNCTION {field.or.null} +{ duplicate$ empty$ + { pop$ "" } + 'skip$ + if$ +} + +FUNCTION {emphasize} +{ duplicate$ empty$ + { pop$ "" } + { "{\it " swap$ * "\/}" * } + if$ +} + +FUNCTION {bolden} +{ duplicate$ empty$ + { pop$ "" } + { "{\bf " swap$ * "}" * } + if$ +} + + +FUNCTION {capitalize} +{ "u" change.case$ "t" change.case$ } + +FUNCTION {space.word} +{ " " swap$ * " " * } + + % Here are the language-specific definitions for explicit words. + % Each function has a name bbl.xxx where xxx is the English word. + % The language selected here is ENGLISH +FUNCTION {bbl.and} +{ "and"} + +FUNCTION {bbl.etal} +{ "et~al." } + +FUNCTION {bbl.editors} +{ "eds." } + +FUNCTION {bbl.editor} +{ "ed." } + +FUNCTION {bbl.edby} +{ "edited by" } + +FUNCTION {bbl.edition} +{ "edn." } + +FUNCTION {bbl.volume} +{ "vol." } + +FUNCTION {bbl.of} +{ "of" } + +FUNCTION {bbl.number} +{ "no." } + +FUNCTION {bbl.nr} +{ "no." } + +FUNCTION {bbl.in} +{ "in" } + +FUNCTION {bbl.pages} +{ "pp." } + +FUNCTION {bbl.page} +{ "p." } + +FUNCTION {bbl.chapter} +{ "chap." } + +FUNCTION {bbl.techrep} +{ "Tech. Rep." } + +FUNCTION {bbl.mthesis} +{ "Master's thesis" } + +FUNCTION {bbl.phdthesis} +{ "Ph.D. thesis" } + +FUNCTION {bbl.first} +{ "First" } + +FUNCTION {bbl.second} +{ "Second" } + +FUNCTION {bbl.third} +{ "Third" } + +FUNCTION {bbl.fourth} +{ "Fourth" } + +FUNCTION {bbl.fifth} +{ "Fifth" } + +FUNCTION {bbl.st} +{ "st" } + +FUNCTION {bbl.nd} +{ "nd" } + +FUNCTION {bbl.rd} +{ "rd" } + +FUNCTION {bbl.th} +{ "th" } + +MACRO {jan} {"Jan."} + +MACRO {feb} {"Feb."} + +MACRO {mar} {"Mar."} + +MACRO {apr} {"Apr."} + +MACRO {may} {"May"} + +MACRO {jun} {"Jun."} + +MACRO {jul} {"Jul."} + +MACRO {aug} {"Aug."} + +MACRO {sep} {"Sep."} + +MACRO {oct} {"Oct."} + +MACRO {nov} {"Nov."} + +MACRO {dec} {"Dec."} + +FUNCTION {eng.ord} +{ duplicate$ "1" swap$ * + #-2 #1 substring$ "1" = + { bbl.th * } + { duplicate$ #-1 #1 substring$ + duplicate$ "1" = + { pop$ bbl.st * } + { duplicate$ "2" = + { pop$ bbl.nd * } + { "3" = + { bbl.rd * } + { bbl.th * } + if$ + } + if$ + } + if$ + } + if$ +} + + %------------------------------------------------------------------- + % Begin module: + % \ProvidesFile{physjour.mbs}[1999/02/24 2.0d (PWD)] +MACRO {aa}{"Astron. \& Astrophys."} +MACRO {aasup}{"Astron. \& Astrophys. Suppl. Ser."} +MACRO {aph} {"Acta Phys."} +MACRO {advp} {"Adv. Phys."} +MACRO {ajp} {"Amer. J. Phys."} +MACRO {ajm} {"Amer. J. Math."} +MACRO {amsci} {"Amer. Sci."} +MACRO {anofd} {"Ann. Fluid Dyn."} +MACRO {am} {"Ann. Math."} +MACRO {ap} {"Ann. Phys. (NY)"} +MACRO {adp} {"Ann. Phys. (Leipzig)"} +MACRO {ao} {"Appl. Opt."} +MACRO {apl} {"Appl. Phys. Lett."} +MACRO {app} {"Astroparticle Phys."} +MACRO {apj} {"Astrophys. J."} +MACRO {apjsup} {"Astrophys. J. Suppl. Ser."} +MACRO {baps} {"Bull. Amer. Phys. Soc."} +MACRO {cmp} {"Comm. Math. Phys."} +MACRO {cpam} {"Commun. Pure Appl. Math."} +MACRO {cppcf} {"Comm. Plasma Phys. \& Controlled Fusion"} +MACRO {cpc} {"Comp. Phys. Comm."} +MACRO {cqg} {"Class. Quant. Grav."} +MACRO {cra} {"C. R. Acad. Sci. A"} +MACRO {fed} {"Fusion Eng. \& Design"} +MACRO {ft} {"Fusion Tech."} +MACRO {grg} {"Gen. Relativ. Gravit."} +MACRO {ieeens} {"IEEE Trans. Nucl. Sci."} +MACRO {ieeeps} {"IEEE Trans. Plasma Sci."} +MACRO {ijimw} {"Interntl. J. Infrared \& Millimeter Waves"} +MACRO {ip} {"Infrared Phys."} +MACRO {irp} {"Infrared Phys."} +MACRO {jap} {"J. Appl. Phys."} +MACRO {jasa} {"J. Acoust. Soc. America"} +MACRO {jcp} {"J. Comp. Phys."} +MACRO {jetp} {"Sov. Phys.--JETP"} +MACRO {jfe} {"J. Fusion Energy"} +MACRO {jfm} {"J. Fluid Mech."} +MACRO {jmp} {"J. Math. Phys."} +MACRO {jne} {"J. Nucl. Energy"} +MACRO {jnec} {"J. Nucl. Energy, C: Plasma Phys., Accelerators, Thermonucl. Res."} +MACRO {jnm} {"J. Nucl. Mat."} +MACRO {jpc} {"J. Phys. Chem."} +MACRO {jpp} {"J. Plasma Phys."} +MACRO {jpsj} {"J. Phys. Soc. Japan"} +MACRO {jsi} {"J. Sci. Instrum."} +MACRO {jvst} {"J. Vac. Sci. \& Tech."} +MACRO {nat} {"Nature"} +MACRO {nature} {"Nature"} +MACRO {nedf} {"Nucl. Eng. \& Design/Fusion"} +MACRO {nf} {"Nucl. Fusion"} +MACRO {nim} {"Nucl. Inst. \& Meth."} +MACRO {nimpr} {"Nucl. Inst. \& Meth. in Phys. Res."} +MACRO {np} {"Nucl. Phys."} +MACRO {npb} {"Nucl. Phys. B"} +MACRO {nt/f} {"Nucl. Tech./Fusion"} +MACRO {npbpc} {"Nucl. Phys. B (Proc. Suppl.)"} +MACRO {inc} {"Nuovo Cimento"} +MACRO {nc} {"Nuovo Cimento"} +MACRO {pf} {"Phys. Fluids"} +MACRO {pfa} {"Phys. Fluids A: Fluid Dyn."} +MACRO {pfb} {"Phys. Fluids B: Plasma Phys."} +MACRO {pl} {"Phys. Lett."} +MACRO {pla} {"Phys. Lett. A"} +MACRO {plb} {"Phys. Lett. B"} +MACRO {prep} {"Phys. Rep."} +MACRO {pnas} {"Proc. Nat. Acad. Sci. USA"} +MACRO {pp} {"Phys. Plasmas"} +MACRO {ppcf} {"Plasma Phys. \& Controlled Fusion"} +MACRO {phitrsl} {"Philos. Trans. Roy. Soc. London"} +MACRO {prl} {"Phys. Rev. Lett."} +MACRO {pr} {"Phys. Rev."} +MACRO {physrev} {"Phys. Rev."} +MACRO {pra} {"Phys. Rev. A"} +MACRO {prb} {"Phys. Rev. B"} +MACRO {prc} {"Phys. Rev. C"} +MACRO {prd} {"Phys. Rev. D"} +MACRO {pre} {"Phys. Rev. E"} +MACRO {ps} {"Phys. Scripta"} +MACRO {procrsl} {"Proc. Roy. Soc. London"} +MACRO {rmp} {"Rev. Mod. Phys."} +MACRO {rsi} {"Rev. Sci. Inst."} +MACRO {science} {"Science"} +MACRO {sciam} {"Sci. Am."} +MACRO {sam} {"Stud. Appl. Math."} +MACRO {sjpp} {"Sov. J. Plasma Phys."} +MACRO {spd} {"Sov. Phys.--Doklady"} +MACRO {sptp} {"Sov. Phys.--Tech. Phys."} +MACRO {spu} {"Sov. Phys.--Uspeki"} + % End module: physjour.mbs +%% Copyright 1994-1999 Patrick W Daly +MACRO {acmcs} {"ACM Comput. Surv."} + +MACRO {acta} {"Acta Inf."} + +MACRO {cacm} {"Commun. ACM"} + +MACRO {ibmjrd} {"IBM J. Res. Dev."} + +MACRO {ibmsj} {"IBM Syst.~J."} + +MACRO {ieeese} {"IEEE Trans. Softw. Eng."} + +MACRO {ieeetc} {"IEEE Trans. Comput."} + +MACRO {ieeetcad} + {"IEEE Trans. Comput.-Aided Design Integrated Circuits"} + +MACRO {ipl} {"Inf. Process. Lett."} + +MACRO {jacm} {"J.~ACM"} + +MACRO {jcss} {"J.~Comput. Syst. Sci."} + +MACRO {scp} {"Sci. Comput. Programming"} + +MACRO {sicomp} {"SIAM J. Comput."} + +MACRO {tocs} {"ACM Trans. Comput. Syst."} + +MACRO {tods} {"ACM Trans. Database Syst."} + +MACRO {tog} {"ACM Trans. Gr."} + +MACRO {toms} {"ACM Trans. Math. Softw."} + +MACRO {toois} {"ACM Trans. Office Inf. Syst."} + +MACRO {toplas} {"ACM Trans. Prog. Lang. Syst."} + +MACRO {tcs} {"Theoretical Comput. Sci."} + + +INTEGERS { nameptr namesleft numnames } + +FUNCTION {format.names} +{ 's := + "" 't := + #1 'nameptr := + s num.names$ 'numnames := + numnames 'namesleft := + { namesleft #0 > } + { s nameptr + "{f.~}{vv~}{ll}{, jj}" format.name$ + 't := + nameptr #1 > + { + nameptr #1 + #1 + = + numnames #50 + > and + { "others" 't := + #1 'namesleft := } + 'skip$ + if$ + namesleft #1 > + { ", " * t * } + { + "," * + s nameptr "{ll}" format.name$ duplicate$ "others" = + { 't := } + { pop$ } + if$ + t "others" = + { + " " * bbl.etal emphasize * + } + { " " * t * } + if$ + } + if$ + } + 't + if$ + nameptr #1 + 'nameptr := + namesleft #1 - 'namesleft := + } + while$ +} + +FUNCTION {format.names.ed} +{ format.names } + +FUNCTION {format.authors} +{ author empty$ + { "" } + { author format.names } + if$ +} + +FUNCTION {format.editors} +{ editor empty$ + { "" } + { editor format.names + ", " * + editor num.names$ #1 > + 'bbl.editors + 'bbl.editor + if$ + * + } + if$ +} + +FUNCTION {format.in.editors} +{ editor empty$ + { "" } + { editor format.names.ed + } + if$ +} + +FUNCTION {format.note} +{ + note empty$ + { "" } + { note #1 #1 substring$ + duplicate$ "{" = + 'skip$ + { output.state mid.sentence = + { "l" } + { "u" } + if$ + change.case$ + } + if$ + note #2 global.max$ substring$ * + } + if$ +} + +FUNCTION {format.title} +{ title empty$ + { "" } + { title "t" change.case$ + } + if$ +} + +FUNCTION {output.bibitem} +{ newline$ + "\bibitem{" write$ + cite$ write$ + "}" write$ + newline$ + "" + before.all 'output.state := +} + +FUNCTION {n.dashify} +{ + 't := + "" + { t empty$ not } + { t #1 #1 substring$ "-" = + { t #1 #2 substring$ "--" = not + { "--" * + t #2 global.max$ substring$ 't := + } + { { t #1 #1 substring$ "-" = } + { "-" * + t #2 global.max$ substring$ 't := + } + while$ + } + if$ + } + { t #1 #1 substring$ * + t #2 global.max$ substring$ 't := + } + if$ + } + while$ +} + +FUNCTION {word.in} +{ "" } + +FUNCTION {format.date} +{ year empty$ + { "" } + 'year + if$ + duplicate$ empty$ + 'skip$ + { + before.all 'output.state := + " (" swap$ * ")" * + } + if$ +} + +FUNCTION {format.btitle} +{ title emphasize +} + +FUNCTION {tie.or.space.connect} +{ duplicate$ text.length$ #3 < + { "~" } + { " " } + if$ + swap$ * * +} + +FUNCTION {either.or.check} +{ empty$ + 'pop$ + { "can't use both " swap$ * " fields in " * cite$ * warning$ } + if$ +} + +FUNCTION {format.bvolume} +{ volume empty$ + { "" } + { bbl.volume volume tie.or.space.connect + series empty$ + 'skip$ + { bbl.of space.word * series emphasize * } + if$ + "volume and number" number either.or.check + } + if$ +} + +FUNCTION {format.number.series} +{ volume empty$ + { number empty$ + { series field.or.null } + { output.state mid.sentence = + { bbl.number } + { bbl.number capitalize } + if$ + number tie.or.space.connect + series empty$ + { "there's a number but no series in " cite$ * warning$ } + { bbl.in space.word * series * } + if$ + } + if$ + } + { "" } + if$ +} + +FUNCTION {is.num} +{ chr.to.int$ + duplicate$ "0" chr.to.int$ < not + swap$ "9" chr.to.int$ > not and +} + +FUNCTION {extract.num} +{ duplicate$ 't := + "" 's := + { t empty$ not } + { t #1 #1 substring$ + t #2 global.max$ substring$ 't := + duplicate$ is.num + { s swap$ * 's := } + { pop$ "" 't := } + if$ + } + while$ + s empty$ + 'skip$ + { pop$ s } + if$ +} + +FUNCTION {convert.edition} +{ edition extract.num "l" change.case$ 's := + s "first" = s "1" = or + { bbl.first 't := } + { s "second" = s "2" = or + { bbl.second 't := } + { s "third" = s "3" = or + { bbl.third 't := } + { s "fourth" = s "4" = or + { bbl.fourth 't := } + { s "fifth" = s "5" = or + { bbl.fifth 't := } + { s #1 #1 substring$ is.num + { s eng.ord 't := } + { edition 't := } + if$ + } + if$ + } + if$ + } + if$ + } + if$ + } + if$ + t +} + +FUNCTION {format.edition} +{ edition empty$ + { "" } + { output.state mid.sentence = + { convert.edition "l" change.case$ " " * bbl.edition * } + { convert.edition "t" change.case$ " " * bbl.edition * } + if$ + } + if$ +} + +INTEGERS { multiresult } + +FUNCTION {multi.page.check} +{ 't := + #0 'multiresult := + { multiresult not + t empty$ not + and + } + { t #1 #1 substring$ + duplicate$ "-" = + swap$ duplicate$ "," = + swap$ "+" = + or or + { #1 'multiresult := } + { t #2 global.max$ substring$ 't := } + if$ + } + while$ + multiresult +} + +FUNCTION {format.pages} +{ pages empty$ + { "" } + { pages multi.page.check + { bbl.pages pages n.dashify tie.or.space.connect } + { bbl.page pages tie.or.space.connect } + if$ + } + if$ +} + +FUNCTION {first.page} +{ 't := + "" + { t empty$ not t #1 #1 substring$ "-" = not and } + { t #1 #1 substring$ * + t #2 global.max$ substring$ 't := + } + while$ +} + +FUNCTION {format.journal.pages} +{ pages empty$ + 'skip$ + { duplicate$ empty$ + { pop$ format.pages } + { + ", " * + pages first.page * + } + if$ + } + if$ +} + +FUNCTION {format.vol.num.pages} +{ volume field.or.null + bolden + format.journal.pages +} + +FUNCTION {format.chapter.pages} +{ chapter empty$ + 'format.pages + { type empty$ + { bbl.chapter } + { type "l" change.case$ } + if$ + chapter tie.or.space.connect + pages empty$ + 'skip$ + { ", " * format.pages * } + if$ + } + if$ +} + +FUNCTION {format.in.ed.booktitle} +{ booktitle empty$ + { "" } + { editor empty$ + { word.in booktitle emphasize * } + { word.in booktitle emphasize * + ", " * + format.in.editors * + ", " * + editor num.names$ #1 > + { bbl.editors } + { bbl.editor } + if$ + * + } + if$ + } + if$ +} + +FUNCTION {empty.misc.check} +{ author empty$ title empty$ howpublished empty$ + month empty$ year empty$ note empty$ + and and and and and + { "all relevant fields are empty in " cite$ * warning$ } + 'skip$ + if$ +} + +FUNCTION {format.thesis.type} +{ type empty$ + 'skip$ + { pop$ + type "t" change.case$ + } + if$ +} + +FUNCTION {format.tr.number} +{ type empty$ + { bbl.techrep } + 'type + if$ + number empty$ + { "t" change.case$ } + { number tie.or.space.connect } + if$ +} + +FUNCTION {format.article.crossref} +{ + key empty$ + { journal empty$ + { "need key or journal for " cite$ * " to crossref " * crossref * + warning$ + "" + } + { word.in journal emphasize * } + if$ + } + { word.in key * " " *} + if$ + " \cite{" * crossref * "}" * +} + +FUNCTION {format.crossref.editor} +{ editor #1 "{vv~}{ll}" format.name$ + editor num.names$ duplicate$ + #2 > + { pop$ + " " * bbl.etal emphasize * + } + { #2 < + 'skip$ + { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" = + { + " " * bbl.etal emphasize * + } + { bbl.and space.word * editor #2 "{vv~}{ll}" format.name$ + * } + if$ + } + if$ + } + if$ +} + +FUNCTION {format.book.crossref} +{ volume empty$ + { "empty volume in " cite$ * "'s crossref of " * crossref * warning$ + word.in + } + { bbl.volume volume tie.or.space.connect + bbl.of space.word * + } + if$ + editor empty$ + editor field.or.null author field.or.null = + or + { key empty$ + { series empty$ + { "need editor, key, or series for " cite$ * " to crossref " * + crossref * warning$ + "" * + } + { series emphasize * } + if$ + } + { key * } + if$ + } + { format.crossref.editor * } + if$ + " \cite{" * crossref * "}" * +} + +FUNCTION {format.incoll.inproc.crossref} +{ + editor empty$ + editor field.or.null author field.or.null = + or + { key empty$ + { booktitle empty$ + { "need editor, key, or booktitle for " cite$ * " to crossref " * + crossref * warning$ + "" + } + { word.in booktitle emphasize * } + if$ + } + { word.in key * " " *} + if$ + } + { word.in format.crossref.editor * " " *} + if$ + " \cite{" * crossref * "}" * +} + +FUNCTION {format.org.or.pub} +{ 't := + "" + year empty$ + { "empty year in " cite$ * warning$ } + 'skip$ + if$ + address empty$ t empty$ and + year empty$ and + 'skip$ + { + add.blank "(" * + t empty$ + { address empty$ + 'skip$ + { address * } + if$ + } + { t * + address empty$ + 'skip$ + { ", " * address * } + if$ + } + if$ + year empty$ + 'skip$ + { t empty$ address empty$ and + 'skip$ + { ", " * } + if$ + year * + } + if$ + ")" * + } + if$ +} + +FUNCTION {format.publisher.address} +{ publisher empty$ + { "empty publisher in " cite$ * warning$ + "" + } + { publisher } + if$ + format.org.or.pub +} + +FUNCTION {format.organization.address} +{ organization empty$ + { "" } + { organization } + if$ + format.org.or.pub +} + +FUNCTION {article} +{ output.bibitem + format.authors "author" output.check + format.title "title" output.check + crossref missing$ + { journal + emphasize + "journal" output.check + add.blank + format.vol.num.pages output + format.date "year" output.check + } + { format.article.crossref output.nonnull + format.pages output + } + if$ + new.sentence + format.note output + fin.entry +} + +FUNCTION {arxiv} +{ output.bibitem + format.authors "author" output.check + crossref missing$ + { journal + emphasize + "journal" output.check + add.blank + format.vol.num.pages output + format.date "year" output.check + } + { format.article.crossref output.nonnull + format.pages output + } + if$ + new.sentence + format.note output + fin.entry +} + +FUNCTION {book} +{ output.bibitem + author empty$ + { format.editors "author and editor" output.check + } + { format.authors output.nonnull + crossref missing$ + { "author and editor" editor either.or.check } + 'skip$ + if$ + } + if$ + format.btitle "title" output.check + crossref missing$ + { format.bvolume output + format.number.series output + format.publisher.address output + } + { + format.book.crossref output.nonnull + format.date "year" output.check + } + if$ + format.edition output + new.sentence + format.note output + fin.entry +} + +FUNCTION {booklet} +{ output.bibitem + format.authors output + format.title "title" output.check + howpublished output + address output + format.date output + new.sentence + format.note output + fin.entry +} + +FUNCTION {inbook} +{ output.bibitem + author empty$ + { format.editors "author and editor" output.check + } + { format.authors output.nonnull + crossref missing$ + { "author and editor" editor either.or.check } + 'skip$ + if$ + } + if$ + format.btitle "title" output.check + crossref missing$ + { + format.number.series output + format.publisher.address output + format.bvolume output + format.chapter.pages "chapter and pages" output.check + } + { + format.chapter.pages "chapter and pages" output.check + format.book.crossref output.nonnull + format.date "year" output.check + } + if$ + format.edition output + new.sentence + format.note output + fin.entry +} + +FUNCTION {incollection} +{ output.bibitem + format.authors "author" output.check + crossref missing$ + { format.in.ed.booktitle "booktitle" output.check + format.number.series output + format.publisher.address output + format.bvolume output + format.chapter.pages output + format.edition output + } + { format.incoll.inproc.crossref output.nonnull + format.chapter.pages output + } + if$ + new.sentence + format.note output + fin.entry +} + +FUNCTION {inproceedings} +{ output.bibitem + format.authors "author" output.check + crossref missing$ + { format.in.ed.booktitle "booktitle" output.check + format.number.series output + publisher empty$ + { format.organization.address output } + { organization output + format.publisher.address output + } + if$ + format.bvolume output + format.pages output + } + { format.incoll.inproc.crossref output.nonnull + format.pages output + } + if$ + new.sentence + format.note output + fin.entry +} + +FUNCTION {conference} { inproceedings } + +FUNCTION {manual} +{ output.bibitem + author empty$ + { organization empty$ + 'skip$ + { organization output.nonnull + address output + } + if$ + } + { format.authors output.nonnull } + if$ + format.btitle "title" output.check + author empty$ + { organization empty$ + { + address output + } + 'skip$ + if$ + } + { + organization output + address output + } + if$ + format.edition output + format.date output + new.sentence + format.note output + fin.entry +} + +FUNCTION {mastersthesis} +{ output.bibitem + format.authors "author" output.check + format.title "title" output.check + bbl.mthesis format.thesis.type output.nonnull + school "school" output.check + address output + format.date "year" output.check + new.sentence + format.note output + fin.entry +} + +FUNCTION {misc} +{ output.bibitem + format.authors output + format.title output + howpublished output + format.date output + new.sentence + format.note output + fin.entry + empty.misc.check +} + +FUNCTION {phdthesis} +{ output.bibitem + format.authors "author" output.check + format.title "title" output.check + bbl.phdthesis format.thesis.type output.nonnull + school "school" output.check + address output + format.date "year" output.check + new.sentence + format.note output + fin.entry +} + +FUNCTION {proceedings} +{ output.bibitem + editor empty$ + { organization output } + { format.editors output.nonnull } + if$ + format.btitle "title" output.check + format.bvolume output + editor empty$ + { publisher empty$ + 'skip$ + { + format.number.series output + format.publisher.address output + } + if$ + } + { publisher empty$ + { + format.organization.address output } + { + organization output + format.publisher.address output + } + if$ + } + if$ + new.sentence + format.note output + fin.entry +} + +FUNCTION {techreport} +{ output.bibitem + format.authors "author" output.check + format.title "title" output.check + format.tr.number emphasize output.nonnull + institution "institution" output.check + address output + format.date "year" output.check + new.sentence + format.note output + fin.entry +} + +FUNCTION {unpublished} +{ output.bibitem + format.authors "author" output.check + format.title "title" output.check + format.date output + new.sentence + format.note "note" output.check + fin.entry +} + +FUNCTION {default.type} { misc } + +READ + +STRINGS { longest.label } + +INTEGERS { number.label longest.label.width } + +FUNCTION {initialize.longest.label} +{ "" 'longest.label := + #1 'number.label := + #0 'longest.label.width := +} + +FUNCTION {longest.label.pass} +{ number.label int.to.str$ 'label := + number.label #1 + 'number.label := + label width$ longest.label.width > + { label 'longest.label := + label width$ 'longest.label.width := + } + 'skip$ + if$ +} + +EXECUTE {initialize.longest.label} + +ITERATE {longest.label.pass} + +FUNCTION {begin.bib} +{ preamble$ empty$ + 'skip$ + { preamble$ write$ newline$ } + if$ + "\begin{thebibliography}{" longest.label * "}" * + write$ newline$ +} + +EXECUTE {begin.bib} + +EXECUTE {init.state.consts} + +ITERATE {call.type$} + +FUNCTION {end.bib} +{ newline$ + "\end{thebibliography}" write$ newline$ +} + +EXECUTE {end.bib} +%% End of customized bst file +%% +%% End of file `Science.bst'. diff --git a/inst/rmarkdown/templates/science/skeleton/scibib.bib b/inst/rmarkdown/templates/science/skeleton/scibib.bib new file mode 100644 index 000000000..d8a66af21 --- /dev/null +++ b/inst/rmarkdown/templates/science/skeleton/scibib.bib @@ -0,0 +1,35 @@ +@misc{nattex, note="One of the equation editors we use, Equation Magic +(MicroPress Inc., Forest Hills, NY; http://www.micropress-inc.com/), +interprets native \TeX\ source code and generates an equation as an +OLE picture object that can then be cut and pasted directly into Word. +This editor, however, does not handle \LaTeX\ environments (such as +\texttt{\{array\}} or \texttt{\{eqnarray\}}); it can interpret only +\TeX\ codes. Thus, when there's a choice, we ask that you avoid these +\LaTeX\ calls in displayed math --- for example, that you use the +\TeX\ \verb+\matrix+ command for ordinary matrices, rather than the +\LaTeX\ \texttt{\{array\}} environment."} + + + + +@book{king1994designing, + title={Designing Social Inquiry: Scientific Inference in Qualitative Research}, + author={King, Gary and Keohane, Robert O and Verba, Sidney}, + year={1994}, + publisher={Princeton University Press} +} + +@article{ho2007matching, + title={Matching as nonparametric preprocessing for reducing model dependence in parametric causal inference}, + author={Ho, Daniel E and Imai, Kosuke and King, Gary and Stuart, Elizabeth A}, + journal={Political analysis}, + volume={15}, + number={3}, + pages={199--236}, + year={2007}, + publisher={Cambridge University Press} +} + + + + diff --git a/inst/rmarkdown/templates/science/skeleton/scicite.sty b/inst/rmarkdown/templates/science/skeleton/scicite.sty new file mode 100644 index 000000000..fa2779d58 --- /dev/null +++ b/inst/rmarkdown/templates/science/skeleton/scicite.sty @@ -0,0 +1,513 @@ +% What follows is a slightly modified version of D. Arseneau's +% cite.sty style file, to take into account the form of references +% for the journal Science. We have left all copyright information +% intact, as instructed by the author of the original file. + + + + +% C I T E . S T Y +% +% version 4.01 (Nov 2003) +% +% Compressed, sorted lists of on-line or superscript numerical citations. +% see also drftcite.sty (And the stub overcite.sty) +% +% Copyright (C) 1989-2003 by Donald Arseneau +% These macros may be freely transmitted, reproduced, or modified +% provided that this notice is left intact. +% +% Instructions follow \endinput. +% ------------------------------------ +% First, ensure that some catcodes have the expected values +\edef\citenum{% to restore funny codes + \catcode\string`\string ` \the\catcode\string`\` + \catcode\string`\string ' \the\catcode\string`\' + \catcode\string`\string = \the\catcode\string`\= + \catcode\string`\string _ \the\catcode\string`\_ + \catcode\string`\string : \the\catcode\string`\:} +\catcode\string`\` 12 +\catcode`\' 12 +\catcode`\= 12 +\catcode`\_ 8 +\catcode`\: 12 + +% Handle optional variations: +% [ verbose, nospace, space, ref, nosort, noadjust, superscript, nomove ], +% \citeform,\citeleft,\citeright,\citemid,\citepunct,\citedash +% +% Set defaults: + +% Science change -- ( on the left, per Science Style. +\providecommand\citeleft{(} + +% Science change -- ) on the right: +\providecommand\citeright{)} + +% Science addition -- biblabel changed to numerals with periods. +\renewcommand\@biblabel[1]{#1.} + +% , (comma space) before note +\providecommand\citemid{,\penalty\@medpenalty\ } + +% , (comma thin-space) between entries; [nospace] eliminates the space +\providecommand\citepunct{,\penalty\@m\hskip.13emplus.1emminus.1em}% + +% -- (endash) designating range of numbers: +% (using \hbox avoids easy \exhyphenpenalty breaks) +\providecommand{\citedash}{\hbox{--}\penalty\@m} + +% Each number left as-is: +\providecommand\citeform{} + +% punctuation characters to move for overcite +\providecommand{\CiteMoveChars}{.,:;} + +% font selection for superscript numbers +\providecommand\OverciteFont{\fontsize\sf@size\baselineskip\selectfont} + + +% Do not repeat warnings. [verbose] reverses +\let\oc@verbo\relax + +% Default is to move punctuation: +\def\oc@movep#1{\futurelet\@tempb\@citey} + +%---------------------- +% \citen uses \@nocite to ignore spaces after commas, and write the aux file +% \citation. \citen then loops over the citation tags, using \@make@cite@list +% to make a sorted list of numbers. Finally, \citen executes \@citelist to +% compress ranges of numbers and print the list. \citen can be used by itself +% to give citation numbers without the brackets and other formatting; e.g., +% "See also ref.~\citen{junk}." +% +\DeclareRobustCommand\citen[1]{% + \begingroup + \let\@safe@activesfalse\@empty + \@nocite{#1}% ignores spaces, writes to .aux file, returns #1 in \@no@sparg + \@tempcntb\m@ne % \@tempcntb tracks highest number + \let\@h@ld\@empty % nothing held from list yet + \let\@citea\@empty % no punctuation preceding first + \let\@celt\delimiter % an unexpandable, but identifiable, token + \def\@cite@list{}% % empty list to start + \@for \@citeb:=\@no@sparg\do{\@make@cite@list}% make a sorted list of numbers + % After sorted citelist is made, execute it to compress citation ranges. + \@tempcnta\m@ne % no previous number + \let\@celt\@compress@cite \@cite@list % output number list with compression + \@h@ld % output anything held over + \endgroup + \@restore@auxhandle + } + +% For each citation, check if it is defined and if it is a number. +% if a number: insert it in the sorted \@cite@list +% otherwise: output it immediately. +% +\def\@make@cite@list{% + \expandafter\let \expandafter\@B@citeB + \csname b@\@citeb\@extra@b@citeb \endcsname + \ifx\@B@citeB\relax % undefined: output ? and warning + \@citea {\bfseries ?}\let\@citea\citepunct \G@refundefinedtrue + \@warning {Citation `\@citeb' on page \thepage\space undefined}% + \oc@verbo \global\@namedef{b@\@citeb\@extra@b@citeb}{?}% + \else % defined % remove previous line to repeat warnings + \ifcat _\ifnum\z@<0\@B@citeB _\else A\fi % a positive number, put in list + \@addto@cite@list + \else % citation is not a number, output immediately + \@citea \citeform{\@B@citeB}\let\@citea\citepunct + \fi\fi} + +% Regular definition for adding entry to cite list, with sorting + +\def\@addto@cite@list{\@tempcnta\@B@citeB \relax + \ifnum \@tempcnta>\@tempcntb % new highest, add to end (efficiently) + \edef\@cite@list{\@cite@list \@celt{\@B@citeB}}% + \@tempcntb\@tempcnta + \else % arbitrary number: insert appropriately + \edef\@cite@list{\expandafter\@sort@celt \@cite@list \@gobble @}% + \fi} +% +% \@sort@celt inserts number (\@tempcnta) into list of \@celt{num} (#1{#2}) +% \@celt must not be expandable; list should end with two vanishing tokens. +% +\def\@sort@celt#1#2{\ifx \@celt #1% parameters are \@celt {num} + \ifnum #2<\@tempcnta % number goes later in list + \@celt{#2}% + \expandafter\expandafter\expandafter\@sort@celt % continue + \else % number goes here + \@celt{\number\@tempcnta}\@celt{#2}% stop comparing +\fi\fi} + +% Check if each number follows previous and can be put in a range +% +\def\@compress@cite#1{% % This is executed for each number + \advance\@tempcnta\@ne % Now \@tempcnta is one more than the previous number + \ifnum #1=\@tempcnta % Number follows previous--hold on to it + \ifx\@h@ld\@empty % first pair of successives + \expandafter\def\expandafter\@h@ld\expandafter{\@citea + \citeform{#1}}% + \else % compressible list of successives + \def\@h@ld{\citedash \citeform{#1}}% + \fi + \else % non-successor -- dump what's held and do this one + \@h@ld \@citea \citeform{#1}% + \let\@h@ld\@empty + \fi \@tempcnta#1\let\@citea\citepunct +} + +% Make \cite choose superscript or normal + +\DeclareRobustCommand{\cite}{% + \@ifnextchar[{\@tempswatrue\@citex}{\@tempswafalse\@citex[]}} + +% Do \cite command on line. +% +\def\@citex[#1]#2{\@cite{\citen{#2}}{#1}} + +% Modified by Science for italic number, roman parentheses. + +\def\@cite#1#2{\leavevmode \cite@adjust + \citeleft{\itshape {#1\if@tempswa\@safe@activesfalse\citemid{#2}\fi + \spacefactor\@m % punctuation in note doesn't affect outside + }}\citeright + \@restore@auxhandle} + +% Put a penalty before the citation, and adjust the spacing: if no space +% already or if there is extra space due to some punctuation, then change +% to one inter-word space. +% +\def\cite@adjust{\begingroup% + \@tempskipa\lastskip \edef\@tempa{\the\@tempskipa}\unskip + \ifnum\lastpenalty=\z@ \penalty\@highpenalty \fi + \ifx\@tempa\@zero@skip \spacefactor1001 \fi % if no space before, set flag + \ifnum\spacefactor>\@m \ \else \hskip\@tempskipa \fi + \endgroup} + + +\edef\@zero@skip{\the\z@skip} + +% Superscript cite, with no optional note. Check for punctuation first. +% +\def\@citew#1{\begingroup \leavevmode + \@if@fillglue \lastskip \relax \unskip + \def\@tempa{\@tempcnta\spacefactor + \/% this allows the last word to be hyphenated, and it looks better. + \@citess{\citen{#1}}\spacefactor\@tempcnta + \endgroup \@restore@auxhandle}% + \oc@movep\relax}% check for following punctuation (depending on options) + +% Move trailing punctuation before the citation: +% +\def\@citey{\let\@tempc\@tempa + % Watch for double periods and suppress them + \ifx\@tempb.\ifnum\spacefactor<\@bigSfactor\else + \let\@tempb\relax \let\@tempc\oc@movep + \fi\fi + % Move other punctuation + \expandafter\@citepc\CiteMoveChars\delimiter + \@tempc}% + +\def\@citepc#1{% + \ifx\@tempb#1\@empty #1\let\@tempc\oc@movep \fi + \ifx\delimiter#1\else \expandafter\@citepc\fi} + +% Replacement for \@cite which defines the formatting normally done +% around the citation list. This uses superscripts with no brackets. +% HOWEVER, trailing punctuation has already been moved over. The +% format for cites with note is given by \@cite. Redefine \@cite and/ +% or \@citex to get different appearance. I don't use \textsuperscript +% because it is defined BADLY in compatibility mode. + +\def\@citess#1{\mbox{$\m@th^{\hbox{\OverciteFont{#1}}}$}} + +% \nocite: This is changed to ignore *ALL* spaces and be robust. The +% parameter list, with spaces removed, is `returned' in \@no@sparg, which +% is used by \citen. +% +\DeclareRobustCommand\nocite[1]{% + \@bsphack \@nocite{#1}% + \@for \@citeb:=\@no@sparg\do{\@ifundefined{b@\@citeb\@extra@b@citeb}% + {\G@refundefinedtrue\@warning{Citation `\@citeb' undefined}% + \oc@verbo \global\@namedef{b@\@citeb\@extra@b@citeb}{?}}{}}% + \@esphack} + +\def\@nocite#1{\begingroup\let\protect\string% normalize active chars + \xdef\@no@sparg{\expandafter\@ignsp#1 \: }\endgroup% and remove ALL spaces + \if@filesw \immediate\write\@newciteauxhandle % = \@auxout, except with multibib + {\string\citation {\@no@sparg}}\fi + } + +% for ignoring *ALL* spaces in the input. This presumes there are no +% \outer tokens and no \if-\fi constructs in the parameter. Spaces inside +% braces are retained. +% +\def\@ignsp#1 {\ifx\:#1\@empty\else #1\expandafter\@ignsp\fi} + +% \@if@fillglue{glue}{true}{false} +\begingroup + \catcode`F=12 \catcode`I=12\catcode`L=12 + \lowercase{\endgroup + \def\@if@fillglue#1{% + \begingroup \skip@#1\relax + \expandafter\endgroup\expandafter + \@is@fil@ \the\skip@ \relax\@firstoftwo FIL\relax\@secondoftwo\@nil} + \def\@is@fil@ #1FIL#2\relax#3#4\@nil{#3} +} + +\let\nocitecount\relax % in case \nocitecount was used for drftcite + +% For the time being, just prevent gross errors from using hyperref. +% There are no hyper-links. (I will need to carry the cite tags through +% the sorting process, and use \hyper@natlinkstart) + +\providecommand\hyper@natlinkstart[1]{} +\providecommand\hyper@natlinkend{} +\providecommand\NAT@parse{\@firstofone} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% option processing + +\DeclareOption{verbose}{\def\oc@verbo#1#2#3#4{}} +\DeclareOption{nospace}{\def\citepunct{,\penalty\@m}} +\DeclareOption{space}{\def\citepunct{,\penalty\@highpenalty\ }} +\DeclareOption{ref}{\def\citeleft{[Ref.\penalty\@M\ }} +\DeclareOption{nosort}{\def\@addto@cite@list + {\edef\@cite@list{\@cite@list \@celt{\@B@citeB}}}} +\DeclareOption{sort}{}% default! +\DeclareOption{nomove}{\def\oc@movep{\@tempa}\let\@citey\oc@movep} +\DeclareOption{move}{}% default +\DeclareOption{nocompress}{% + \def\@compress@cite#1{% % This is executed for each number + \@h@ld \@citea \hyper@natlinkstart\citeform{#1}\hyper@natlinkend + \let\@h@ld\@empty \let\@citea\citepunct} +} +\DeclareOption{compress}{}% default +\DeclareOption{super}{\ExecuteOptions{superscript}} +\DeclareOption{superscript}{% + \DeclareRobustCommand{\cite}{% + \@ifnextchar[{\@tempswatrue\@citex}{\@tempswafalse\@citew}} +} +\DeclareOption{noadjust}{\let\cite@adjust\@empty}% Don't change spaces +\DeclareOption{adjust}{}% adjust space before [ ] +\DeclareOption{biblabel}{\def\@biblabel#1{\@citess{#1}\kern-\labelsep\,}} +\ProvidesPackage{scicite}[2003/11/04 \space v 4.01] +\ProcessOptions + +\ifx\@citey\oc@movep\else % we are moving punctuation; must ensure sfcodes + \mathchardef\@bigSfactor3000 + \expandafter\def\expandafter\frenchspacing\expandafter{\frenchspacing + \mathchardef\@bigSfactor1001 + \sfcode`\.\@bigSfactor \sfcode`\?\@bigSfactor \sfcode`\!\@bigSfactor }% + \ifnum\sfcode`\.=\@m \frenchspacing \fi +\fi + +% Compatability with chapterbib (see use of \@extra@b@citeb) +\@ifundefined{@extra@b@citeb}{\def\@extra@b@citeb{}}{} + +% Compatability with multibib (see use of \@newciteauxhandle) (Yes, this is +% overly messy, but I asked for it... I can't have multibib putting junk after +% the cite command because it hides following punctuation, but then I have +% to restore the ordinary meaning of \@newciteauxhandle = \@auxout.) +\providecommand\@newciteauxhandle{\@auxout} +\AtBeginDocument{\@ifundefined{newcites}{\global\let\@restore@auxhandle\relax}{}} +\def\@restore@auxhandle{\def\@newciteauxhandle{\@auxout}} + + +\@ifundefined{G@refundefinedtrue}{\let\G@refundefinedtrue\relax}{} + +\@ifundefined{@safe@activesfalse}{}{} +\@ifundefined{bbl@cite@choice}{}{\@ifundefined{org@@citex}{}% + {\let\org@@citex\@citex}}% Prevent stomping by babel + + +\citenum % execute restore-catcodes + +% Aliases: +\let\citenum\citen +\let\citeonline\citen + +\endinput +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + + CITE.STY + +Modify LaTeX's normal citation mechanism to: + +o Put a comma and a small space between each citation number. The option + [nospace] removes that space, and the option [space] replaces it with + an ordinary inter-word space. + +o Sort citation numbers into ascending order, printing non-numbers before + numbers. All numbers should be greater than zero. The [nosort] package + option turns off sorting. + +o Compress lists of three or more consecutive numbers to one number range + which can be split, with difficulty, after the dash. All numbers should + be greater than zero. E.g., if you used to get the (nonsense) list + [7,5,6,?,4,9,8,Einstein,6], then this style will give [?,Einstein,4-6,6-9]. + Compression of ranges is disabled by the [nocompress] package option. + +o Allow, but strongly discourage, line breaks within a series of + citations. Each number is separated by a comma and a small space. + A break at the beginning of an optional note is discouraged also. + +o Put a high-penalty breakpoint before the citation (unless you specifically + forbid it with ~ ). Also, adjust the spacing: if there is no space or if + there is extra space due to some punctuation, then change to one inter-word + space. E.g., A space will be inserted here\cite{Larry,Curly,Moe}. + +o With package option [superscript] (or [super] for short), display citation + numbers as superscripts (unless they have optional notes, causing them to + be treated as described above). Superscripted citations follow these + additional rules: + +- Superscript citations use THE SAME INPUT FORMAT as ordinary citations; this + style will ignore spaces before the citation, and move trailing punctuation + before the superscript citation. For example, "information \cite{source};" + ignores the space before \cite and puts the semicolon before the number, just + as if you had typed "information;$^{12}$". You may switch off movement with + the [nomove] package option (only relevant with [superscript]). + +- The punctuation characters that will migrate before the superscript are + listed in the macro \CiteMoveChars, which you can redefine. The default is + .,;:. Perhaps ! and ? should too, but they weren't listed in the APS style + manual I looked at, and I agree with that rule to prevent too much visual + separation. Quotes were listed, but they should never have to migrate + because both on-line and superscript versions put quotes before the citation. + This gives one difficulty --- punctuation following quotes won't migrate + inside the quotation: e.g., "``Transition State Theory''\cite{Eyring}." gives + "``Transition State Theory''.$^8$", but you may want the period inside the + quotes, thus: ``Transition State Theory.''$^8$. + +- Doubling of periods (.., ?., !.) is checked for and suppressed. The spacing + after the citation is set according to the final punctuation mark moved. + There is a problem with double periods after a capitalized abbreviation + or directly after \@ : Both of "N.A.S.A. \cite{space}." and "et al.\@ + \cite{many}." will give doubled periods. These can be fixed as follows: + "N.A.S.A\@. \cite{space}." and "et al.\ \cite{many}.". The NASA example + gives the wrong spacing when there is no citation. Sorry. Use \ after + abbreviations like et al. to get the right spacing within a sentence whether + or not a citation follows. + +- Remember, these rules regarding punctuation only apply when the [superscript] + option was given (or overcite.sty used) and the [nomove] option was NOT + given. + +o Define \citen to get just the numbers without the brackets or superscript + and extra formatting. Aliases are \citenum and \citeonline for easy + conversion to other citation packages. + +o `Citation...undefined' warnings are only given once per undefined citation + tag. In the text, missing numbers are represented with a bold `?' at the + first occurrence, and with a normal `?' thenceforth. The package option + [verbose] restores the usual repeated warnings. + +o Make \nocite, \cite, and \citen all ignore spaces in the input tags. + +Although each \cite command sorts its numbers, better compression into +ranges can usually be achieved by carefully selecting the order of the +\bibitem entries or the order of initial citations when using BibTeX. +Having the entries pre-sorted will also save processing time, especially +for long lists of numbers. + +Customization: +~~~~~~~~~~~~~~ +There are several options for \usepackage{cite}, some already mentioned. + + [superscript] use superscrpts for cites without optional notes + [super] alias for [superscript] (like natbib) + [verbose] causes warnings for undefined cites to be repeated each time + [ref] uses the format "[Ref.~12, optional note]" (useful with + the superscript option) + [nospace] eliminates the spaces after commas in the number list. + [space] uses a full inter-word space after the commas + [nosort] prevents sorting of the numbers (default is to sort, and a + [sort] option is provided for completeness). + [nomove] prevents moving the superscript cite after punctuation. + [move] is the default + [noadjust] disables `smart' handling of space before a cite + [adjust] is the default + [nocompress] inhibit compression of consecutive numbers into ranges + [compress] is the default + [biblabel] define the bibliography label as a superscript + +There are several commands that you may redefine to change the formatting +of citation lists: + +command function default +---------- ----------------------- ---------------------------- +\citeform reformats each number nothing +\citepunct printed between numbers comma + penalty + thin space +\citeleft left delimiter of list [ +\citeright right delimeter of list ] +\citemid printed before note comma + space +\citedash used in a compressed range endash + penalty +\CiteMoveChars charcters that move .,:; +\OverciteFont font selection command for superscripts + +The left/mid/right commands don't affect the formatting of superscript +citations. You may use \renewcommand to change any of these. Remember, +these commands are extensions made by this package; they are not regular +LaTeX. Some examples of changes: + +1: \renewcommand\citeform[1]{\romannumeral 0#1}} % roman numerals i,vi +2: \renewcommand\citeform[1]{(#1)} % parenthesized numbers (1)-(5),(9) +3: \renewcommand\citeform{\thechapter.} % by chapter: ^{2.18-2.21} +4: \renewcommand\citepunct{,} % no space and no breaks at commas +5: \renewcommand\citemid{; } % semicolon before optional note +6: \renewcommand\citeleft{(} % parentheses around list with note + \renewcommand\citeright{)} % parentheses around list with note + +The appearance of the whole citation list is governed by \@cite, (for full- +sized cites) and \@citess (for superscripts). For more extensive changes +to the formatting, redefine these. For example, to get brackets around the +list of superscript numbers you can do: + + \def\@citess#1{\textsuperscript{[#1]}} + +after \makeatletter. + +Related Note: The superscript option does not affect the numbering format +of the bibliography; the "[12]" style is still the default. To get +superscripts in the bibliography (at any time) you can define + + \renewcommand\@biblabel[1]{\textsuperscript{#1}} + +Aw, OK, for your convenience, there is the [biblabel] package option that +just performs this definition (sort of). + +\@extra@b@citeb is a hook for other style files to further specify +citations; for example, to number by chapter (see chapterbib.sty). + +% Version 1991: Ignore spaces after commas in the parameter list. Move most of +% \citen into \@cmpresscites for speed. Give the proper \spacefactor afterwards. +% Version 1992: make \citepunct hold the punctuation between numbers (for ease +% of changing). Add \/ to allow hyphenation of previous word, and look better +% in italics. +% 1992a: Make it work with NFSS. (Thank you C. Hamlin and Rainer Schoepf) +% +% Version 3.0 (1992): Rewrite, including sorting. Make entries like "4th" +% be treated properly as text. +% 3.1: Bug fixes (and Joerg-Martin Schwarz also convinced me to use \ifcat) +% 3.2: NFSS support was wrong--added \reset@font. Suppress repetitions of +% warnings. Include \@extra@b@citeb hook. +% 3.3: Handle LaTeX2e options. Introduce various customization hooks. +% 3.4: Heuristics to avoid removing \hspace glue before on-line \cite. +% Make \nocite ignore spaces in list, simplify. Aliases for \citen. +% Compatability with amsmath (which defines \over). +% 3.5: Replace \reset@font with \selectfont so italics are preserved +% Include \G@refundefinedtrue. Fix cite-with-note bug (Lars Engebretsen). +% 3.6: Add nosort option. +% 3.7: Add nomove option; catcode preservation and global \@no@sparg for +% french.sty; warnings in \nocite. +% 3.8: \citedash hook, fix token look-ahead (Heiko Selber), noadjust, babel. +% 3.9: More babel-compatibility hacks. Punctuation move with \frencspacing. +% 4.0: Combine overcite with cite: [superscript] option. Also add [nocompress] +% option and \CiteMoveChars; multibib hooks. +% 4.01 \bf -> \bfseries +% +% Send problem reports to asnd@triumf.ca + +Test file integrity: ASCII 32-57, 58-126: !"#$%&'()*+,-./0123456789 +:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ diff --git a/inst/rmarkdown/templates/science/skeleton/skeleton.Rmd b/inst/rmarkdown/templates/science/skeleton/skeleton.Rmd new file mode 100644 index 000000000..e8f266c5b --- /dev/null +++ b/inst/rmarkdown/templates/science/skeleton/skeleton.Rmd @@ -0,0 +1,191 @@ +--- +title: Template for *Science* Articles +authors: + - name: V. O. Key + affiliation: 1 + corresponding_author: true + - name: Sidney Verba + affiliation: "1,2" # (multiple affiliations shold be quoted and separated by a comma) + - name: Marvin Zelen + affiliation: 3 + - name: Robert Dahl + affiliation: 4 +address: + - code: 1 + address: Harvard University, Department of Government, Cambridge, MA 02138 + - code: 2 + address: Harvard University, Institute for Quantitative Social Science, Cambridge, MA 02138 + - code: 3 + address: Harvard University, Department of Biostatistics, Cambridge, MA 02138 + - code: 4 + address: Yale University, Department of Political Science, Yale, CT 06520 +corresponding_author: "To whom correspondence should be addressed; E-mail: key@harvard.edu." +abstract: | + Enter the text of your abstract here. +acknowledgements: | + Please include your acknowledgments here, set in a single paragraph. +supplementary-materials: + - Materials and Methods + - Supplementary Text + - Figs. S1 to S3 + - Tables S1 to S4 + - References (4-10) +bibliography: scibib.bib +number_sections: false +output: + rticles::science_article: + keep_tex: true + draft: true + move_figures: false +--- + +# Introduction + +This is a basic implementation of the Science template. + +# Uniform Distributions + +Uniform distributions text with Figure. + +```{r once, echo=FALSE, fig.cap='test once', fig.align='center', out.width='50%'} +plot(runif(10)) +``` + +And post uniform distributions text... + +| title | row | +| ----- | --- | +| once | 1 | +| once | 2 | + +: Table caption 1 + + +With a table. + +# Poisson Distributions + +Poisson distributions text... + +```{r twice, echo=FALSE, fig.cap='test twice'} +plot(rpois(10,1)) +``` + +And post Poisson distributions text... + +| title | row | +| ------ | --- | +| twice | 1 | +| twice | 2 | + +: Table caption 2 + +With a table for something. + +# Formatting Citations + +Please separate multiple citations within a single command using commas only; there should be {\it no space between reference keynames. +That is, if you are citing two papers whose bibliography keys are `@king1994designing` and `@ho2007matching`, the in-text cite should read `[@king1994designing; @ho2007matching]` [@ho2007matching;@ho2007matching]. + +\noindent Failure to follow these guidelines could lead +to the omission of the references in an accepted paper when the source +file is translated to Word via HTML. + +# Handling Math, Tables, and Figures + +Following are a few things to keep in mind in coding equations, +tables, and figures for submission to {\it Science}. + +**In-line math.** The utility that we use for converting +from \LaTeX\ to HTML handles in-line math relatively well. It is best +to avoid using built-up fractions in in-line equations, and going for +the more boring "slash" presentation whenever possible --- that is, +for \verb+$a/b$+ (which comes out as $a/b$) rather than +\verb+$\frac{a}{b}$+ (which compiles as $\frac{a}{b}$). Likewise, +HTML isn't tooled to handle certain overaccented special characters +in-line; for $\hat{\alpha}$ (coded \verb+$\hat{\alpha}$+), for +example, the HTML translation code will return [\^{}$(\alpha)$]. +Don't drive yourself crazy --- but if it's possible to avoid such +constructs, please do so. Please do not code arrays or matrices as +in-line math; display them instead. And please keep your coding as +\TeX-y as possible --- avoid using specialized math macro packages +like `amstex.sty`. + +**Displayed math.** Our HTML converter sets up \TeX\ +displayed equations using nested HTML tables. That works well for an +HTML presentation, but Word chokes when it comes across a nested +table in an HTML file. We surmount that problem by simply cutting the +displayed equations out of the HTML before it's imported into Word, +and then replacing them in the Word document using either images or +equations generated by a Word equation editor. Strictly speaking, +this procedure doesn't bear on how you should prepare your manuscript +--- although, for reasons best consigned to a note `\cite{nattex}`, we'd +prefer that you use native \TeX\ commands within displayed-math +environments, rather than \LaTeX\ sub-environments. + +**Tables.** The HTML converter that we use seems to handle +reasonably well simple tables generated using the \LaTeX\ +`tabular` environment. For very complicated tables, you +may want to consider generating them in a word processing program and +including them as a separate file. + +**Figures.** For an initial submission and review copy, you can +use the \LaTeX\ `figure` environment and the +`\includegraphics` command to include your PostScript figures at +the end of the compiled PostScript file. For the final revision, +however, the `figure` environment should *not* be used; +instead, the figure captions themselves should be typed in as regular +text at the end of the source file (an example is included here), and +the figures should be uploaded separately according to the Art +Department's instructions. + + +# What to Send In + +What you should send to *Science* will depend on the stage your manuscript is in: + + +1. **Important**: If you're sending in the initial submission of + your manuscript (that is, the copy for evaluation and peer review), + please send in *only* a PostScript or PDF version of the + compiled file (including figures). Please do not send in the \TeX\ + source, `.sty`, `.bbl`, or other associated files with + your initial submission. (For more information, please see the + instructions at our Web submission site, + http://www.submit2science.org/ .) +2. When the time comes for you to send in your revised final + manuscript (i.e., after peer review), we require that you include + all source files and generated files in your upload. Thus, if the + name of your main source document is `ltxfile.tex`, you + need to include: + 1. `ltxfile.tex`. + 2. `ltxfile.aux`, the auxilliary file generated by the + compilation. + 3. A PostScript file (compiled using `dvips` or some other + driver) of the `.dvi` file generated from + `ltxfile.tex`, or a PDF file distilled from that + PostScript. You do not need to include the actual `.dvi` + file in your upload. + 4. From BibTeX users, your bibliography (`.bib`) + file, *and* the generated file `ltxfile.bbl` created + when you run BibTeX. + 5. Any additional `.sty` and `.bst` files called by the source code (though, for reasons noted earlier, we *strongly* discourage the use of such files beyond those mentioned in this document). + +# Appendix +\appendix +Appendix figures and tables will also need to be moved. A basic example is provided here so this feature is also tested. + +First we have a figure. + +```{r thrice, echo=FALSE, fig.cap='test thrice'} +plot(rnorm(10)) +``` + +And next we have a table + +| title | row | +| ------ | --- | +| twice | 1 | +| twice | 2 | + +: Appendix table caption diff --git a/inst/rmarkdown/templates/science/template.yaml b/inst/rmarkdown/templates/science/template.yaml new file mode 100644 index 000000000..886ad55fe --- /dev/null +++ b/inst/rmarkdown/templates/science/template.yaml @@ -0,0 +1,4 @@ +name: Science Advances Journal Article +description: > + This template is for authors who are preparing a manuscript to the Science Advances journal. +create_dir: true diff --git a/man/rticles-package.Rd b/man/rticles-package.Rd index 64dbba5ae..59e46acb5 100644 --- a/man/rticles-package.Rd +++ b/man/rticles-package.Rd @@ -78,6 +78,8 @@ Other contributors: \item Callum Arnold \email{cal.rk.arnold@gmail.com} (arnold-c) [contributor] \item Dmytro Perepolkin \email{dperepolkin@gmail.com} (\href{https://orcid.org/0000-0001-8558-6183}{ORCID}) (dmi3kno) [contributor] \item Tom Palmer \email{remlapmot@hotmail.com} (\href{https://orcid.org/0000-0003-4655-4511}{ORCID}) (remlapmot) [contributor] + \item Christopher T. Kenny \email{christopherkenny@fas.harvard.edu} (\href{https://orcid.org/0000-0002-9386-6860}{ORCID}) (christopherkenny) [contributor] + \item Shiro Kuriwaki \email{shirokuriwaki@gmail.com} (\href{https://orcid.org/0000-0002-5687-2647}{ORCID}) (kuriwaki) [contributor] } } diff --git a/man/science_article.Rd b/man/science_article.Rd new file mode 100644 index 000000000..bfcbc11a6 --- /dev/null +++ b/man/science_article.Rd @@ -0,0 +1,44 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/science_article.R +\name{science_article} +\alias{science_article} +\title{Science Journal Format} +\usage{ +science_article( + ..., + keep_tex = TRUE, + move_figures = TRUE, + move_tables = TRUE, + number_sections = FALSE, + draft = TRUE, + pandoc_args = NULL +) +} +\arguments{ +\item{...}{Additional arguments to \code{\link[rmarkdown:pdf_document]{rmarkdown::pdf_document()}}} + +\item{keep_tex}{Keep the intermediate tex file used in the conversion to PDF. +Note that this argument does not control whether to keep the auxiliary +files (e.g., \file{.aux}) generated by LaTeX when compiling \file{.tex} to +\file{.pdf}. To keep these files, you may set \code{options(tinytex.clean = +FALSE)}.} + +\item{move_figures}{set to \code{TRUE} to move figures to end. Default is \code{TRUE}. Only +works when \code{draft == TRUE}.} + +\item{move_tables}{set to \code{TRUE} to move tables to end. Default is \code{TRUE}. Only +works when \code{draft == TRUE}.} + +\item{number_sections}{\code{TRUE} to number section headings} + +\item{draft}{set to \code{TRUE} for the draft version or \code{FALSE} for a +final submission version. \code{TRUE} moves the supplemental +materials to its own file.} + +\item{pandoc_args}{Additional command line options to pass to pandoc} +} +\description{ +Format for creating submissions to Science. Based on the Science +\href{https://www.sciencemag.org/site/feature/contribinfo/prep/TeX_help/#downloads}{class}. +Note that this template only works for \code{bibtext} with \code{natbib} for citations. +} diff --git a/tests/testit/test-formats.R b/tests/testit/test-formats.R index 9ac05cd5b..b7b727dc9 100644 --- a/tests/testit/test-formats.R +++ b/tests/testit/test-formats.R @@ -77,6 +77,7 @@ test_format("rjournal") test_format("rsos") test_format("rss") test_format("sage") +test_format("science") test_format("sim") test_format("springer", skip = !rmarkdown::pandoc_available("2.11.4")) test_format("tf")