Skip to content

Commit 136c182

Browse files
committed
Adds package option enables, adds a few new hooks to template, and cleans up a few areas
1 parent f23d093 commit 136c182

File tree

7 files changed

+198
-26
lines changed

7 files changed

+198
-26
lines changed

R/ieee_article.R

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,27 @@
44
#' \href{http://www.ieee.org/publications_standards/publications/authors/author_templates.html}{http://www.ieee.org/publications_standards/publications/authors/author_templates.html}.
55
#'
66
#' @inheritParams rmarkdown::pdf_document
7+
#' @param draftmode Specify the draft mode to control spacing and whether images
8+
#' should be rendered. Valid options are: \code{"final"} (default), \code{"draft"},
9+
#' \code{"draftcls"}, or \code{"draftclsnofoot"}.
10+
#' @param hyphenfixes A \code{character} value that provides the correct
11+
#' hyphenations for ambiguous words. Separate new words with spaces.
12+
#' @param IEEEspecialpaper A \code{character} value containing the publication's
13+
#' special paper designation.
14+
#' @param with_ifpdf A \code{logical} value turning on (\code{TRUE}) or off
15+
#' (\code{FALSE}) the \code{ifpdf} LaTeX package.
16+
#' @param with_cite A \code{logical} value turning on (\code{TRUE}) or off
17+
#' (\code{FALSE}) the \code{cite} LaTeX package.
18+
#' @param with_amsmath A \code{logical} value turning on (\code{TRUE}) or off
19+
#' (\code{FALSE}) the \code{amsmath} LaTeX package.
20+
#' @param with_algorithmic A \code{logical} value turning on (\code{TRUE}) or
21+
#' off (\code{FALSE}) the \code{algorithmic} LaTeX package.
22+
#' @param with_subfig A \code{logical} value turning on (\code{TRUE}) or off
23+
#' (\code{FALSE}) the \code{subfig} LaTeX package.
24+
#' @param with_array A \code{logical} value turning on (\code{TRUE}) or off
25+
#' (\code{FALSE}) the \code{array} LaTeX package.
26+
#' @param with_dblfloatfix A \code{logical} value turning on (\code{TRUE}) or
27+
#' off (\code{FALSE}) the \code{dblfloatfix} LaTeX package.
728
#' @param ... Additional arguments to \code{rmarkdown::pdf_document}
829
#'
930
#' @return R Markdown output format to pass to
@@ -16,11 +37,65 @@
1637
#' draft("MyArticle.Rmd", template = "ieee_article", package = "rticles")
1738
#' }
1839
#'
40+
#' @details
41+
#' Presently, only the \code{"conference"} paper mode offered by the
42+
#' \code{IEEEtran.cls} is supported.
43+
#'
44+
#' @references
45+
#' Shell, Michael. "How to use the IEEEtran LATEX class." Journal of LATEX Class
46+
#' Files 1.11 (2002): 10-20.
47+
#' \url{http://mirrors.rit.edu/CTAN/macros/latex/contrib/IEEEtran/IEEEtran_HOWTO.pdf}
1948
#' @export
2049
ieee_article <- function(...,
21-
keep_tex = TRUE,
22-
md_extensions = c("-autolink_bare_uris")) {
50+
draftmode = c("final", "draft", "draftcls",
51+
"draftclsnofoot"),
52+
hyphenfixes = "op-tical net-works semi-conduc-tor",
53+
IEEEspecialpaper = "",
54+
with_ifpdf = FALSE,
55+
with_cite = FALSE,
56+
with_amsmath = FALSE,
57+
with_algorithmic = FALSE,
58+
with_subfig = FALSE,
59+
with_array = FALSE,
60+
with_dblfloatfix = FALSE,
61+
keep_tex = TRUE,
62+
md_extensions = c("-autolink_bare_uris")) {
63+
64+
args <- c()
65+
66+
draftmode <- match.arg(draftmode)
67+
args <- c(args, "draftmode" = draftmode)
68+
69+
args <- c(args, "hyphenfixes" = hyphenfixes)
70+
71+
# Avoid declaration of pandoc variable if field is empty
72+
if(nchar(IEEEspecialpaper) > 1){
73+
args <- c(args, "IEEEspecialpaper" = IEEEspecialpaper)
74+
}
75+
76+
plist <- c("with_ifpdf" = with_ifpdf,
77+
"with_cite" = with_cite,
78+
"with_amsmath" = with_amsmath,
79+
"with_algorithmic" = with_algorithmic,
80+
"with_subfig" = with_subfig,
81+
"with_array" = with_array,
82+
"with_dblfloatfix" = with_dblfloatfix)
83+
84+
# Obtain only variables that should be turned on
85+
requested_withs <- sapply(plist, isTRUE)
86+
87+
args <- c(args, plist[requested_withs])
88+
89+
# pandoc_variable_arg not exported from rmarkdown
90+
pandoc_arg_variable = function(var_name, value){
91+
c("-V", paste0(var_name, "=", value))
92+
}
93+
94+
# Convert to pandoc arguments
95+
pandoc_arg_list <- mapply(pandoc_arg_variable, names(args), args)
96+
2397
inherit_pdf_document(...,
98+
pandoc_args = pandoc_arg_list,
2499
template = find_resource("ieee_article", "template.tex"),
25100
keep_tex = keep_tex,
26101
md_extensions = md_extensions)

inst/NEWS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
rticles 0.2.0.9000
2+
---------------------------------------------------------------------
3+
4+
- Add Institute of Electrical and Electronics Engineers (IEEE) IEEEtrans
5+
template for Conferences
6+
17

28
rticles 0.2
39
---------------------------------------------------------------------

inst/rmarkdown/templates/ieee_article/resources/template.tex

Lines changed: 65 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
% The testflow support page is at:
5151
% http://www.michaelshell.org/tex/testflow/
5252

53-
\documentclass[conference]{IEEEtran}
53+
\documentclass[conference,$if(fontsize)$$fontsize$,$endif$$if(draftmode)$$draftmode$,$endif$$if(papersize)$$papersize$,$endif$$for(classoption)$$classoption$$sep$,$endfor$]{IEEEtran}
5454
% Some Computer Society conferences also require the compsoc mode option,
5555
% but others use the standard conference format.
5656
%
@@ -68,6 +68,9 @@
6868

6969
% *** MISC UTILITY PACKAGES ***
7070
%
71+
$if(with_ifpdf)$
72+
\usepackage{ifpdf}
73+
$endif$
7174
%\usepackage{ifpdf}
7275
% Heiko Oberdiek's ifpdf.sty is very useful if you need conditional
7376
% compilation based on whether the output is pdf or dvi.
@@ -91,6 +94,9 @@
9194

9295
% *** CITATION PACKAGES ***
9396
%
97+
$if(with_cite)$
98+
\usepackage{cite}
99+
$endif$
94100
%\usepackage{cite}
95101
% cite.sty was written by Donald Arseneau
96102
% V1.6 and later of IEEEtran pre-defines the format of the cite.sty package
@@ -158,6 +164,10 @@
158164

159165
% *** MATH PACKAGES ***
160166
%
167+
$if(with_amsmath)$
168+
\usepackage{amsmath}
169+
\interdisplaylinepenalty=2500
170+
$endif$
161171
%\usepackage{amsmath}
162172
% A popular package from the American Mathematical Society that provides
163173
% many useful and powerful commands for dealing with mathematics.
@@ -176,6 +186,9 @@
176186

177187
% *** SPECIALIZED LIST PACKAGES ***
178188
%
189+
$if(with_algorithmic)$
190+
\usepackage{algorithmic}
191+
$endif$
179192
%\usepackage{algorithmic}
180193
% algorithmic.sty was written by Peter Williams and Rogerio Brito.
181194
% This package provides an algorithmic environment fo describing algorithms.
@@ -196,6 +209,9 @@
196209

197210
% *** ALIGNMENT PACKAGES ***
198211
%
212+
$if(with_array)$
213+
\usepackage{array}
214+
$endif$
199215
%\usepackage{array}
200216
% Frank Mittelbach's and David Carlisle's array.sty patches and improves
201217
% the standard LaTeX2e array and tabular environments to provide better
@@ -243,6 +259,10 @@
243259

244260
% *** FLOAT PACKAGES ***
245261
%
262+
$if(with_dblfloatfix)$
263+
\usepackage{dblfloatfix}
264+
$endif$
265+
246266
%\usepackage{fixltx2e}
247267
% fixltx2e, the successor to the earlier fix2col.sty, was written by
248268
% Frank Mittelbach and David Carlisle. This package corrects a few problems
@@ -312,7 +332,7 @@
312332

313333
$if(natbib)$
314334
\usepackage{natbib}
315-
\bibliographystyle{plainnat}
335+
\bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$}
316336
$endif$
317337
$if(biblatex)$
318338
\usepackage{biblatex}
@@ -324,7 +344,7 @@
324344
$endif$
325345

326346
$if(tables)$
327-
\usepackage{longtable}
347+
\usepackage{longtable,booktabs}
328348
$endif$
329349
$if(graphics)$
330350
\usepackage{graphicx}
@@ -341,21 +361,30 @@
341361

342362
\usepackage[unicode=true]{hyperref}
343363

344-
\hypersetup{breaklinks=true,
345-
bookmarks=true,
346-
pdfauthor={$author-meta$},
364+
\hypersetup{
365+
$if(title-meta)$
347366
pdftitle={$title-meta$},
367+
$endif$
368+
$if(author-meta)$
369+
pdfauthor={$author-meta$},
370+
$endif$
371+
$if(keywords)$
372+
pdfkeywords={$for(keywords)$$keywords$$sep$, $endfor$},
373+
$endif$
374+
$if(colorlinks)$
348375
colorlinks=true,
349-
urlcolor=$if(urlcolor)$$urlcolor$$else$blue$endif$,
350-
linkcolor=$if(linkcolor)$$linkcolor$$else$magenta$endif$,
351-
pdfborder={0 0 0}}
376+
linkcolor=$if(linkcolor)$$linkcolor$$else$Magenta$endif$,
377+
citecolor=$if(citecolor)$$citecolor$$else$Blue$endif$,
378+
urlcolor=$if(urlcolor)$$urlcolor$$else$Blue$endif$,
379+
$else$
380+
pdfborder={0 0 0},
381+
$endif$
382+
breaklinks=true}
352383
\urlstyle{same} % don't use monospace font for urls
353384

354-
$for(header-includes)$
355-
$header-includes$
356-
$endfor$
357385
% Pandoc toggle for numbering sections (defaults to be off)
358386
$if(numbersections)$
387+
\setcounter{secnumdepth}{$if(secnumdepth)$$secnumdepth$$else$5$endif$}
359388
$else$
360389
\setcounter{secnumdepth}{0}
361390
$endif$
@@ -368,11 +397,9 @@
368397
%% END MY ADDITIONS %%
369398

370399

371-
% correct bad hyphenation here
372-
\hyphenation{op-tical net-works semi-conduc-tor}
400+
\hyphenation{$hyphenfixes$}
373401

374402
\begin{document}
375-
376403
%
377404
% paper title
378405
% Titles are generally capitalized except for words such as a, an, and, as,
@@ -389,11 +416,13 @@
389416
\author{
390417
$for(author)$
391418
\IEEEauthorblockN{$author.name$}
392-
\IEEEauthorblockA{$author.affiliation$}
393-
{$author.department$}\\
394-
{$author.location$}\\
395-
{$author.email$}
396-
\and $endfor$
419+
\IEEEauthorblockA{$author.affiliation$\\
420+
$author.department$\\
421+
$author.location$\\
422+
$author.email$
423+
}
424+
$sep$\and
425+
$endfor$
397426
}
398427

399428
% conference papers do not typically use \thanks and this command
@@ -438,6 +467,18 @@
438467

439468
% no keywords
440469

470+
% use for special paper notices
471+
472+
$if(IEEEspecialpaper)$
473+
\IEEEspecialpapernotice{$IEEEspecialpaper$}
474+
$endif$
475+
476+
477+
% make the title area
478+
\maketitle
479+
480+
% no keywords
481+
441482
% For peer review papers, you can put extra information on the cover
442483
% page as needed:
443484
% \ifCLASSOPTIONpeerreview
@@ -448,6 +489,10 @@
448489
% creates the second title. It will be ignored for other modes.
449490
\IEEEpeerreviewmaketitle
450491

492+
$for(include-before)$
493+
$include-before$
494+
495+
$endfor$
451496

452497
$body$
453498

inst/rmarkdown/templates/ieee_article/skeleton/mybibfile.bib

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
@article{Dirac1953888,
22
title = "The lorentz transformation and absolute time",
3-
journal = "Physica ",
3+
journal = "Physica",
44
volume = "19",
5-
number = "1-12",
5+
number = "1--12",
66
pages = "888--896",
77
year = "1953",
88
doi = "10.1016/S0031-8914(53)80099-6",

inst/rmarkdown/templates/ieee_article/skeleton/skeleton.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ author:
1010
affiliation: University of Nevada
1111
department: Civil Engineering
1212
location: Las Vegas, Nevada 89119
13-
email: daniel.emaasit@gmail.com
13+
email: daniel.emaasit@gmail.com
1414
- name: Alice Wonderland
1515
affiliation: Another University
1616
department: Your Department

man/ieee_article.Rd

Lines changed: 46 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test_formats.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ test_format("rjournal_article", file_check = FALSE)
4646
test_format("acs_article", os_skip = "windows")
4747
test_format("pnas_article")
4848
test_format("aea_article")
49+
test_format("ieee_article")
4950

5051

5152

0 commit comments

Comments
 (0)