Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ieee_article() add journal support #375

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
dc3cd5c
initial changes. Is it my tex that is breaking numeric refs?
FluffierThanThou Feb 17, 2021
f6f6249
add IEEE abbreviations bib
FluffierThanThou Feb 22, 2021
03c4825
add IEEE csl, let pandoc sort out the citation mess
FluffierThanThou Feb 22, 2021
dfb06d2
default to using csl (pandoc) for citations instead of latex (bib[la]…
FluffierThanThou Feb 22, 2021
2414372
fix typos, cleanup docs.
FluffierThanThou Feb 24, 2021
1f398c3
add news line and contributor info
FluffierThanThou Feb 24, 2021
9edfd94
remove abbreviations bib file
FluffierThanThou Feb 24, 2021
5eec91b
Merge branch 'master' into Karel-Kroeze-master
cderv Nov 29, 2021
81120b3
Missing comma in description file
cderv Nov 29, 2021
fe30daf
Add the number_section default logic in the R function
cderv Nov 29, 2021
d73b061
Precise the message
cderv Nov 29, 2021
f9db267
Adapt skeleton to new journal mode toggling
cderv Nov 29, 2021
c5f4fb9
Move variable definition in function as it is supported
cderv Nov 29, 2021
2580457
comment out journal mode only YAML param
cderv Nov 29, 2021
c5e813d
Use the CSL as url
cderv Nov 29, 2021
a7020e5
Adapt the affiliation section
cderv Nov 29, 2021
365ead0
Show how to use the pandoc variable instead
cderv Nov 29, 2021
5bbead1
remove duplicate argument
cderv Nov 29, 2021
74c7d69
Support biblatexoption in template
cderv Nov 29, 2021
b68819a
Support citation_package explicitly
cderv Nov 29, 2021
ef6e881
Prevent pandoc error early regarding template syntax
cderv Nov 29, 2021
fe37892
remove empty line
cderv Nov 29, 2021
bdde76c
Update documentation
cderv Nov 29, 2021
5205bff
Update CSL ref part in template
cderv Nov 29, 2021
e44e93d
missing $ in template
cderv Nov 29, 2021
4965d54
Missing command in template
cderv Nov 29, 2021
5d5d9c5
Missing the negation in test
cderv Nov 29, 2021
52765e0
Add an example specific for Journal output in the template bundle
cderv Nov 29, 2021
0315917
Add special case for testing other demo file in bundle
cderv Nov 29, 2021
097e2d0
Update requirement as template requires 2.8
cderv Nov 29, 2021
baeb407
Use character version in pandoc_available()
cderv Nov 29, 2021
54e8118
Update NEWS and bump version
cderv Nov 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: rticles
Type: Package
Title: Article Formats for R Markdown
Version: 0.21.3
Version: 0.21.4
Authors@R: c(
person("JJ", "Allaire", role = "aut", email = "[email protected]"),
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666")),
Expand Down Expand Up @@ -49,7 +49,8 @@ Authors@R: c(
person("Greg", "Macfarlane", role = c("ctb"), email = "[email protected]", comment = c(github = "gregmacfarlane")),
person("Matthias", "Templ", role = c("ctb"), email = "[email protected]", comment = c(ORCID = "0000-0002-8638-5276", github = "matthias-da")),
person("Alvaro", "Uzaheta", role = c("ctb"), email = "[email protected]", comment = c(github = "auzaheta")),
person("JooYoung", "Seo", role=c("ctb"), email="[email protected]", comment = c(ORCID = "0000-0002-4064-6012"))
person("JooYoung", "Seo", role=c("ctb"), email="[email protected]", comment = c(ORCID = "0000-0002-4064-6012")),
person("Karel", "Kroeze", role = c("ctb"), email = "[email protected]", comment = c(ORCID = "0000-0002-7000-7377", github = "karel-kroeze"))
)
Description: A suite of custom R Markdown formats and templates for
authoring journal articles and conference submissions.
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

- Add `trb_article()` for annual meeting submissions to the Transportation Research Board Annual Meeting (thanks, @gregmacfarlane, #427).

- `ieee_article()` now supports journal articles with different defaults, using `journal` classoption for `IEEEtran` document class. This brings a pandoc minimum requirement of 2.8 for conference paper and 2.10 for journal article. A new demo Rmd file has been added in the bundle when creating the template for `ieee_article()` - see this file and help page for new argument and syntax (thanks, @Karel-Kroeze, #375).

# rticles 0.21

## NEW FEATURES
Expand Down
29 changes: 28 additions & 1 deletion R/ieee_article.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@
#' <http://www.ieee.org/publications_standards/publications/authors/author_templates.html>.
#'
#' Presently, only the `"conference"` paper mode offered by the
#' `IEEEtran.cls` is supported.
#' `IEEEtran.cls` is supported, with experimental support for the
#' `"journal"` mode.
#'
#' # Pandoc requirement
#'
#' This format requires at least Pandoc 2.8 and 2.10 when `journal` is used.
#'
#' @inheritParams rmarkdown::pdf_document
#' @param draftmode Specify the draft mode to control spacing and whether images
#' should be rendered. Valid options are: `"final"` (default), `"draft"`,
#' `"draftcls"`, or `"draftclsnofoot"`.
#' @param hyphenfixes A `character` value that provides the correct
#' hyphenations for ambiguous words. Separate new words with spaces.
#' @param journal Running Header to use for a journal paper. When set,
#' classoption `journal` will be used instead of `conference`.
#' `number_sections` will also default to `TRUE` in this case.
#' @param IEEEspecialpaper A `character` value containing the publication's
#' special paper designation.
#' @param with_ifpdf A `logical` value turning on (`TRUE`) or off
Expand Down Expand Up @@ -39,6 +47,7 @@
ieee_article <- function(
draftmode = c("final", "draft", "draftcls", "draftclsnofoot"),
hyphenfixes = "op-tical net-works semi-conduc-tor",
journal = NULL,
IEEEspecialpaper = "",
with_ifpdf = FALSE,
with_cite = FALSE,
Expand All @@ -49,17 +58,34 @@ ieee_article <- function(
with_dblfloatfix = FALSE,
keep_tex = TRUE,
pandoc_args = NULL,
citation_package = "default",
md_extensions = c("-autolink_bare_uris"),
number_sections = FALSE,
...
) {

rmarkdown::pandoc_available("2.8", error = TRUE)

args <- c()

draftmode <- match.arg(draftmode)
args <- c(args, "draftmode" = draftmode)

args <- c(args, "hyphenfixes" = hyphenfixes)


# Some check when journal mode is set
if (!is.null(journal)) {
# Add as Pandoc's variable
args <- c(args, "journal" = journal)
# activate number_section by default
if(missing(number_sections)) number_sections <- TRUE
# New author syntax needs to be used which requires a recent pandoc
if (!rmarkdown::pandoc_available("2.10")) {
stop("Using `journal` mode for `ieee_article()` requires Pandoc >= 2.10", call. = FALSE)
}
}

# Avoid declaration of pandoc variable if field is empty
if (nchar(IEEEspecialpaper) > 1) {
args <- c(args, "IEEEspecialpaper" = IEEEspecialpaper)
Expand All @@ -83,6 +109,7 @@ ieee_article <- function(
pdf_document_format(
"ieee", pandoc_args = c(pandoc_arg_list, pandoc_args),
keep_tex = keep_tex, md_extensions = md_extensions,
number_sections = number_sections, citation_package = citation_package,
...
)
}
53 changes: 35 additions & 18 deletions inst/rmarkdown/templates/ieee/resources/template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@
% The testflow support page is at:
% http://www.michaelshell.org/tex/testflow/

\documentclass[conference,$if(fontsize)$$fontsize$,$endif$$if(draftmode)$$draftmode$,$endif$$if(papersize)$$papersize$,$endif$$for(classoption)$$classoption$$sep$,$endfor$]{IEEEtran}
% *** rticle changes for journal/conference mode.
% adding journal as an override for conference mode to maintain backwards
% compatibility. Any future expansions to further modes will have to come up with
% a cleverer solution, or introduce breaking changes.
\documentclass[$if(journal)$journal$else$conference$endif$,$if(fontsize)$$fontsize$,$endif$$if(draftmode)$$draftmode$,$endif$$if(papersize)$$papersize$,$endif$$for(classoption)$$classoption$$sep$,$endfor$]{IEEEtran}
cderv marked this conversation as resolved.
Show resolved Hide resolved
% Some Computer Society conferences also require the compsoc mode option,
% but others use the standard conference format.
%
Expand Down Expand Up @@ -335,7 +339,7 @@
\bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$}
$endif$
$if(biblatex)$
\usepackage[backend=bibtex,citestyle=ieee,style=numeric$if(citation_sorting)$,sorting=$citation_sorting$$endif$]{biblatex}
\usepackage[backend=bibtex,citestyle=ieee,style=$if(biblio-style)$$biblio-style$$else$numeric$endif$,$if(citation_sorting)$sorting=$citation_sorting$,$endif$$for(biblatexoptions)$$biblatexoptions$$sep$,$endfor$]{biblatex}
$if(bibliography)$
$for(bibliography)$
\addbibresource{$bibliography$}
Expand Down Expand Up @@ -382,7 +386,7 @@
breaklinks=true}
\urlstyle{same} % don't use monospace font for urls

% Pandoc toggle for numbering sections (defaults to be off)
% Pandoc toggle for numbering sections
$if(numbersections)$
\setcounter{secnumdepth}{$if(secnumdepth)$$secnumdepth$$else$5$endif$}
$else$
Expand All @@ -406,15 +410,18 @@
\everypar{\setlength{\hangindent}{\cslhangindent}}\ignorespaces$endif$}%
{\par}
% For Pandoc 2.11+
\newlength{\cslentryspacingunit} % times entry-spacing
\setlength{\cslentryspacingunit}{\parskip}
\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}
\ifodd #1
\let\oldpar\par
\def\par{\hangindent=\cslhangindent\oldpar}
\fi
% set entry spacing
\setlength{\parskip}{#2\cslentryspacingunit}
}%
{}
\usepackage{calc} % for calculating minipage widths
Expand Down Expand Up @@ -447,6 +454,24 @@
% Do not put math or special symbols in the title.
\title{$title$}


% split author affiliations for journal and conference layouts
$if(journal)$

$if(affiliation.author)$
\author{
$for(affiliation.author)$$if(it.last)$and $endif$$it.name$$if(it.member)$, \IEEEmembership{$it.member$}$endif$$sep$, $endfor$
$if(affiliation.thanks)$$for(affiliation.thanks)$\thanks{$affiliation.thanks$}$endfor$$endif$
}
cderv marked this conversation as resolved.
Show resolved Hide resolved
$else$
$~$!!! Only 'affiliation.author' syntax is supported for the journal mode. Modify you YAML header accordingly.$~$
$endif$

\markboth{$journal$$~$, Vol. XX, No. X, XXXXXX 20XX$~$}%
{$title$}

$else$ % -- end if/journal

% author names and affiliations
% use a multiple column layout for up to three different
% affiliations
Expand Down Expand Up @@ -563,6 +588,8 @@
$endif$
}

$endif$ %% -- end else/journal

% conference papers do not typically use \thanks and this command
% is locked out in conference mode. If really needed, such as for
% the acknowledgment of grants, issue a \IEEEoverridecommandlockouts
Expand All @@ -586,14 +613,6 @@
%\IEEEauthorblockA{\IEEEauthorrefmark{4}Tyrell Inc., 123 Replicant Street, Los Angeles, California 90210--4321}}




% use for special paper notices
%\IEEEspecialpapernotice{(Invited Paper)}




% make the title area
\maketitle

Expand All @@ -606,7 +625,7 @@
% keywords
$if(keywords)$
\begin{IEEEkeywords}
$for(keywords)$$keywords$$sep$; $endfor$
$for(keywords)$$keywords$$sep$$if(journal)$, $else$; $endif$$endfor$
cderv marked this conversation as resolved.
Show resolved Hide resolved
\end{IEEEkeywords}
$endif$

Expand Down Expand Up @@ -661,5 +680,3 @@

$endfor$
\end{document}


Loading