Giter Club home page Giter Club logo

pinp's Introduction

pinp: Pinp is not PNAS

CI Package-License CRAN Dependencies Downloads Last Commit

Motivation

The template provided by the PNAS Article template in the rticles package makes it very easy and convenient to create attractive looking two-column papers with an option to switch to a one-column paper.

There were however a few changes we wanted to make such as the use of standard natbib citations, more extended use of color, a different font as well as the removal of a number of PNAS-specific title page items as well as general code and use simplification via a single LaTeX class file. So this pinp package started.

Example

Pinp Vignette

As of release 0.0.2, the package now has a vignette:

Rcpp Vignette

A complete pdf example of the two-column default template is provided here by the new introductory Rcpp vignette, which is itself based on our PeerJ Prepint.

A screenshot of the first two pages:

and the next two pages, showing a two-column figure

followed by pages five and six

and the final two pages:

Other Rcpp vignettes have been converted as well.

Status

The package is working as expected, and available via CRAN.

Usage

Use the standard

install.packages("pinp")

to install it from CRAN, and then use as a Markdown template via RStudio, or use code such as

library(rmarkdown)
draft("mypaper.Rmd", template="pdf", package="pinp", edit=FALSE)
render("mypaper.Rmd")

to create a first draft of a new mypaper.Rmd.

Requirements

Beyond the R package dependencies, a working pandoc binary is needed. RStudio installs its own copy, otherwise do what is needed on your OS (i.e., something like sudo apt-get install pandoc pandoc-citeproc).

The pdf mode requires a fairly complete LaTeX installation, and has been used on Ubuntu and macOS. On Debian/Ubuntu, the following packages should provide a working set:

texlive-base
texlive-binaries
texlive-fonts-extra
texlive-fonts-recommended
texlive-generic-recommended
texlive-humanities
texlive-latex-base
texlive-latex-extra
texlive-latex-recommended
texlive-pictures
texlive-publishers
texlive-science

See also

  • binb: Binb is not Beamer: Stylish pdf Presentations from RMarkdown
  • linl: Linl is not Letter: LaTeX letters from RMarkdown
  • tint: tint is not tufte: Beautiful pdf or html handout or writeups

and the minm package installing all of them.

Authors

Dirk Eddelbuettel and James Balamuta, leaning on the earlier work by JJ et al in the rticles package.

The authors of the underlying PNAS LaTeX Style are not explicitedly listed, but PNAS refers to Overleaf.

License

GPL-3 for this package, as well as the short code taken with grateful acknowledgements from the rticles package.

The main PNAS LaTeX style file (and supporting files) are under the LPPL (LaTeX Project Public License) version 1.3 or later.

pinp's People

Contributors

coatless avatar eddelbuettel avatar espinielli avatar ikashnitsky avatar mnel avatar saghirb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pinp's Issues

automatic DOI links in the reference list

tl;dr -- maybe default bibliography to APA?

I am specifying a custom .csl using the option (apa.csl is in the parent directory)

# citation style
biblio-style: apa

The resulting reference list looks fine. The only issue -- it omits DOI link at the very end. I think it's useful to have a direct link to the papers from the PDF.

bib.tex not part of package?

Has the bib.tex file been intentionally omitted from the pinp package?

From YAML:

# Produce a pinp document
output:
  pinp::pinp:
    includes:
      after_body: bib.tex

Feature request: pnas_type

Hi,

In the package rticles, there is an option called pnas_type : pnasinvited which produces a slightly different output than the default pnasresearcharticle.

Would it please be possible to add this option?

Thank you
Best regards

Enabling Extra PNAS features in the YAML section

This issue ticket will be resolved when:

  • Write the following features alongside fallbacks into the template.tex file so they can be set with yml:
    1. Allow for watermarking the document with true or false (default)
    2. Enabling the doi entry key field and CRAN package URL
    3. Provide footers for the left and right side of the document, where users can add their package or other details.

This has been split off from issue #1

Failed to compile the example using Windows

I tried to install pinp on a computer using Windows 10 in Portuguese and every time I try to compile the package example, I get the following error in my log file:

! pdfTeX error (font expansion): auto expansion is only possible with scalable 
fonts.
\AtBegShi@Output ...ipout \box \AtBeginShipoutBox 
                                                  \fi \fi 
l.234 T
       o allow an equation to span both columns, options are to use the 
Here is how much of TeX's memory you used:
 38326 strings out of 494585
 721011 string characters out of 6176316
 852398 words of memory out of 5000000
 41278 multiletter control sequences out of 15000+600000
 593034 words of font info for 132 fonts, out of 8000000 for 9000
 14 hyphenation exceptions out of 8191
 64i,15n,77p,451b,894s stack positions out of 5000i,500n,10000p,200000b,80000s

!  ==> Fatal error occurred, no output PDF file produced!

I tried both CRAN and github versions on Windows, but they give me the same error. I looked for help on internet (like this post on StackOverflow), but I couldn't find what is wrong with my computer.

My LaTeX engine is TinyTex, based on TexLive. I know it is correctly installed, because the vanilla pdf example from rmarkdown is compiled in my computer.

I don't get what is happening, because I installed pinp on macOS and Ubuntu 18.10 and it works on both systems.

Here is my sessionInfo() if you need to check it.

R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=Portuguese_Brazil.1252  LC_CTYPE=Portuguese_Brazil.1252   
[3] LC_MONETARY=Portuguese_Brazil.1252 LC_NUMERIC=C                      
[5] LC_TIME=Portuguese_Brazil.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.0        rstudioapi_0.8    knitr_1.21        magrittr_1.5     
 [5] usethis_1.4.0     devtools_2.0.1    pkgload_1.0.2     R6_2.3.0         
 [9] rlang_0.3.0.1     tools_3.5.1       pkgbuild_1.0.2    xfun_0.4         
[13] sessioninfo_1.1.1 tinytex_0.9.3     cli_1.0.1         withr_2.1.2      
[17] remotes_2.0.2     htmltools_0.3.6   yaml_2.2.0        assertthat_0.2.0 
[21] digest_0.6.18     rprojroot_1.3-2   crayon_1.3.4      processx_3.2.1   
[25] pinp_0.0.6        callr_3.1.0       fs_1.2.6          ps_1.2.1         
[29] curl_3.2          glue_1.3.0        memoise_1.1.0     evaluate_0.12    
[33] rmarkdown_1.11.2  compiler_3.5.1    backports_1.1.2   desc_1.2.0       
[37] prettyunits_1.0.2

TODO Items

  • Add proper README.md possibly with png of a page or two, could use new Rcpp Intro
  • Rewrite or add lead to skeleton.Rmd to refer to rticles::pnas_article for help
  • Add markdown example for two-column figure
  • Add table example
  • Expand bib file adding PeerJ
  • Give proper credit to PNAS and rticles packages,
    • GPL-3 copyright from rticles carried over,
    • unclear what PNAS / Overleaf copyright terms are besides standard (liberal) TeX / TUG licensing
  • Ideally make all useful features accessible from yaml with fallbacks:
    • Watermark yes/no
    • doi entry, can be used as CRAN package URL
    • Package name used in footer left and right (currently Rcpp hardcoded)
  • A few PNAS sillynesses have been removed such as which author matters more, which conflicts of interest arose, what significance the paper has etc. This could be revisited but as a template for vignettes / paper drafts seems fine
  • Could possibly relax use of the two-col template from PNAS (but 'KISS' rules: simpler as is)

one_column doesn't always work

I was trying to get a one column document, and while there are no errors reported, the pdf produced is empty (though the .tex is produced and can be processed separately, I don't understand enough to know why the result is empty).

I'm attaching a MWE that demonstrates this if you set one_column: true (attachment is .txt to satisfy Github; rename to .Rmd).

MWE.txt

I have pandoc 2.1.3 and other session info is below. I process via:

library("rmarkdown")
render("MWE.Rmd")

Thanks for this very nice package by the way, and any assistance.

> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.4

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] MASS_7.3-49   rmarkdown_1.9

loaded via a namespace (and not attached):
 [1] compiler_3.4.4  backports_1.1.2 magrittr_1.5    rprojroot_1.3-2
 [5] tools_3.4.4     htmltools_0.3.6 yaml_2.1.18     tinytex_0.4    
 [9] Rcpp_0.12.16    pinp_0.0.4      stringi_1.1.7   knitr_1.20     
[13] stringr_1.3.0   digest_0.6.15   evaluate_0.10.1

Support non US-letter paper

PNAS being the Academy of the US, the layout assumes 8.5in by 11in paper. Which is not the standard in the rest of the world.

The code uses the very powerful LaTeX package geometry so there is no reason why a switch could not be added to support, say, a4 paper size. But someone with access to a printer with a4 needs to drive this.

Document some gotchas and workarounds

For example:

  • Writing a figure from hidden R code to pdf and including in latex in order to have two column charts
  • Redefining the final pre-references skip
  • "Man-to-man combat" with the layout algorithm to get all floats placed / weird errors suppressed

pinp breaking under current texlive

KH writes in private email. Has not bitten me yet on Ubuntu...

Pls see
https://cran.r-project.org/web/checks/check_results_pinp.html:
apparently pinp.cls no longer works with current texlive.

For me problems started with the recent Debian testing upgrade to
texlive 2019.20190830-1; for Brian a few days sooner.

My check logs show tlmgr fail because there is no initialized user
tree. If I run tlmgr init-usertree, my logs look like Brian's, modulo
mine using TEXMFHOME (as tlmgr on Debian will not use other locations).

The same problems occur with packages

ChemoSpec ChemoSpec2D RProtoBuf Rcpp RcppArmadillo RcppCNPy
RcppClassic RcppGSL RcppZiggurat mistr pinp readJDX

which are exactly the packages using pinp::pinp to produce a pinp
document.

Of course, tikzlibrarytopaths.code.tex is installed on the check
systems. Nevertheless, knitr asks tinytex to try to install pgf, which
does not help, as compilation still fails with a missing
\begin{document} error in pinp.cls. I suspect what is going on is that
recent texlive changes have invalidated pinp.cls presumably with an
error in tikzlibrarytopaths.code.tex, knitr incorrectly infers that this
is missing and asks tlmgr to install, and then fails again.

Hard to find out more on my end: can you please have a look?

Possible regressions in 0.0.8

The blog post describes some of the reasons why we needed to rush 0.0.8 out -- in essence, pinp was breaking CRAN check because something was afoul with the newest texlive.

I think we have a handle on this, but in upgrading we may have trampled on earlier pull requests and extensions. I am fairly certain that

  • papersize settings and non US support (@saghirb) may be gone (Edit: They are fine.)
  • the date_subtitle (@ikashnitsky) too (Edit: This is too.)
  • possibly other things added by @coatless

In better news we no longer need the skip_final_break stuff @coatless and I did earlier.

For that I apologize. It is my fault as I should have kept the diffs more cleanly in order to reapply them on upgrades -- such as this one. I am fairly confident we can get this back and I will try harder to have a better process. I already added a copy of the current PNAS files so going forward we can diff changes between them.

setting the date manually

It would be very useful to have an option to set the date of the document (running in the footer throughout the document) rather than hard-coded default of \today. It seems that {pinp} ingnores date: "..." in YAML.

Also, it seems very nice to use custom text for the line "This version was compiled on ...". One use case that I see super attractive is to give full bibliographic info for the published post-prints.
Any ideas?

updated look and feel

Various:

  • New font
  • New color scheme for title and headers
  • Equation number update
  • Small other edits
  • Updates in skeleton.Rmd (such as a two-column figures)

inherit from bookdown

Hi,

thank you for this excellent template!

Is there a way I can make it inherit from bookdown instead of the classic Rmarkdown pdf? Rmarkdown cannot reference sections in the documents using @ref, but bookdown does this correctly

thanks

package update requires manual replacement of pinp.bst

This is a small nasty thing that mage me kill several hours twice (with a gap of maybe half a year). Once the package is updated, a fresh cope of pinp.bst is required, and the directory with previously knitted document hold an outdated copy. Maybe there is a way to give an informative message in such a case?

Remove extraneous features of PNAS

The objective of this issue ticket is to clean up the PNAS file by removing features.

  • Remove the following:
    • Author ordering
    • Declaration of conflicts of interest
    • Significance the paper

This has been split off of issue #1

change page numbering

Is it possible to give a custom range of page numbers to a document?
[I have a semi crazy idea to layout PhD thesis as a journal issue using pinp]

Endless loop for some input files

Using the current Rcpp vignettes, I am seeing some misbehaved latex runs on eg Rcpp-package.

I am not yet sure what causes this.

Edit: The \pnasbreak appears to be involved.

Edit 2: Two of the vignettes need a manual \pnasbreak at end with pinp 0.0.3.

pandoc2 changes

Kurt H writes what follows below. Need to change the reference vignette, and the Rcpp* packages using this scheme.

Dirk,
As already mentioned: pls see
https://cran.r-project.org/web/checks/check_results_RcppCNPy.html

Yihui wrote:

The problem is that it seems Pandoc no longer recognizes arbitrary
LaTeX commands in variables set in the YAML metadata. Specifically,
in RcppCNPy-intro.Rmd:

include-after: |
\begin{thebibliography}{4}

This will be escaped to \textbackslash{}begin{thebibliography}{4}
in the .tex output, failing the bibliography. I suggest that the
authors move the values of header-includes and include-after to
separate .tex files, and use the "includes" option of the R Markdown
output format, e.g.,

output:
pinp::pinp:
includes:
in_header: header.tex
after_body: bibliography.tex

Can you pls fix accordingly?

Packages

RcppClassic RcppGSL RcppZiggurat pinp

apparently all have exactly the same problem as RcppCNPy: pls fix those
too.

Best
-k

Tag `pinp` releases

We probably should tag the releases on GitHub.

v0.0.1 - v0.0.3 will need to be done via CLI

git tag -a <tag> <commit-hash>
git push origin --tags

(FYI: releases are MIA on tint and linl)

Class provides

Compiling a pinp document I see

3: LaTeX Warning: You have requested document class `pinp',
               but the document class provides `widetext'.
LaTeX Warning: You have requested document class `pinp',
               but the document class provides `pnasresearcharticle'.

and indeed

edd@rob:~/git/pinp(master)$ grep Provides inst/rmarkdown/templates/pdf/skeleton/pinp.cls 
\ProvidesClass{pinp}[2017-Sep-12, based on pnas-new 28/02/2015, v1.2]
\ProvidesPackage{widetext}
\ProvidesPackage{pnasresearcharticle}[2016/02/28 v1.2 PNAS two column research article style]
edd@rob:~/git/pinp(master)$ 

The second and third need to be commented out.

include-after option

Hi,

The include-after is missing a \input{} from the template.tex. The code

$for(include-after)$
$include-after$
$endfor$

is correctly placed after the bibliography but if we want to include a .tex file, it needs to have a \input{include-after}. Otherwise if we put include-after: somefile.tex in the yaml, then just the words "somefile.tex" will apprear in the .tex.

Putting \input{somefile.tex} in the yaml allows for a workaround. but it's nicer to just put the .tex in the yaml header

Alternative look and feel: pnasinvited

The visual appearance of this is pretty attractive: pnasrticle opting into pnasinvited rather than the default of pnasresearcharticle. The header could change, but the rest is pretty decent too.

image

Default to two-column, two-side, 9pt

In hindsight I think #7 got the defaults wrong.

If nothing is set, we should do 9pt, two-columns, two-sides.

If someone set one-colum: true, they get it. Ditto for one-sided: true,

Preserve non-fancy quotes in code chunks

Using output: pinp::pinp, the quotes in the code chunks are converted to fancy quotes.

I quickly constructed a minimal example as follows

---
title: "Test pinp quotes"
output: pinp::pinp
---

Pinp's quotes in regular text: "dquoted", 'squoted', \`bquoted\`.

Pinp's quotes in inline verbatim text: `"dquoted"`, `'squoted'`.

```r
"dquoted"
'squoted'
`bquoted`
#' Xyz's "dquoted" 'squoted' `bquoted`

(I did not find a nice way to render the closing ``` of the code chunk)

This results in
image

Not sure if this is a desired behavior (I noticed it for the Rcpp vignettes), but in case I tried a quick fix by using LaTeX package upquote. In particular, adding

\RequirePackage{upquote} % For keeping actual quotes in verbatim

to the class definition pinp.cls seemed to indeed help:
image

My LaTeX skills are a bit rusty, so maybe there are more convenient / appropriate ways to achieve the same.

How would this be used?

Formatting before sending out for review?
Formatting of the final version for posting the version that the journal does not own?

Fix Attribution / Credit

This issue ticket will be resolved after:

  1. Adding to the documentation proper acknowledgements for both PNAS and rticles (see #11)
  2. Licensing the package under GPL-3 due to rticles copyleft license
  3. Emphasize the PNAS license terms of PNAS' main style being LaTeX Project Public License >= version 1.3

This has been broken off from issue #1.

figure size

When I do a figure using a

> ```{r, fig.pos='H', fig.cap="Text"}
> some ggplot image
> ```

the figure text font is too large when compared to the regular text (fontsize 9). In regular markdown, I can control that in the yaml header, ex:

output: 
  pdf_document:
    fig_height: 5
    fig_width: 6

But pinp does not offer that option. When I set the options:

knitr::opts_chunk$set(fig.width = 6, fig.height = 5)

it just increases the size of the figure and goes out of the column.

Is there a way to set fig_height and fig_width of the document?

thanks

Supporting other paper sizes

File pinp.cls originally defined the settings for letter paper size but part of these were moved as part of [issue #24] to template.tex to support a4 paper size. [Pull request #55] moved the remaining settings to template.tex to accommodate other paper sizes. This changed the hard-coded PNAS settings for letter paper size to relative ones (not particularly desirable).

The current version of pinp package supports letter and a4 paper sizes. Is this enough? Should we support other paper sizes? If so, should we keep letter paper settings as per PNAS and make the rest relative where the preference would be to try to get it working in pinp.cls?

widetext* environment

Using the widetext* environment gives the following error:

! LaTeX Error: Environment widetext* undefined.

However if I use widetext then the error goes away (as it is defined in pinp.cls). It is also defined as widetext in rticles::pnas_article. For consistency I would change from \begin{widetext*} ... \end{widetext*} to \begin{widetext} ... \end{widetext} in the pinp vignette.

Any thoughts/comments?

Note: Originally from pull request #55.

Simplify authors and affiliations

The current setup is too restrictive and near-broken. If you remove the affiliations section, only the last of several authors is shown.

It would be nice if you could put a few "if set, then..." layers around it to also allow a minimal use case of just one line of Author: with a single entry (or YAML array).

Move remaining `pnas_article()` LaTeX into `template.tex`

I think the following should be moved inside the template.tex file:

<!-- Leave these lines as they are at the end of your .Rmd file to ensure placement of methods & acknowledgements sections before the references-->
\showmatmethods
\showacknow
\pnasbreak 

internationalisation

Hi, thanks for a great package!

I was wondering if you have any plans for supporting internationalisation, either by allowing to set this through babel or another comment? It would be great if dates could be formatted according to different languages and contexts.

Provide pinp.cls if not present

I am a little non-plus'ed that adding pinp as the vignette driver leads to two extra files.

I already figured out how to get rid of one---we can just include the content of the Bibtex-rendered .blg file directly in the source Rmd, which frees us from adding a foo.bib file. Down one. (Of course, you want it while you still edit the document. Once done, and included as a more static vignette you do not and the extra file is line noise.)

And I realized that we have a code hook to just copy in pinp.cls from the pinp skeleton directory if it is not present in the current working directory---and tada we also get rid of pinp.cls.

Good idea? Methinks it is.

Empty space when not including abstract and keywords

I'm trying to use the template where I do not include any abstract and keyword information, and without any text here, there are still 2-3 lines of empty space before the first lines of text in the body of the document starts in column 1. I've been trying to figure out how to get ride of this space so the text in both columns start evenly and so that this space disappears. I'm sure this is an easy fix, but I'm pretty new to working with tex, and I'm stumped. Haven't found anything online in the usual places, I'm hoping someone here might have ideas. Thanks!

Rewrite skeleton.Rmd

Goals of this ticket:

  1. Rewrite skeleton.Rmd with emphasize on removing PNAS specific language. For additional help, add references to rticles::pnas_article
  2. Add a markdown example for two-column figure using LaTeX's figure* environment
    3. [ ] Add table example using knitr::kable(), c.f. yihui/knitr#1221. Unfortunately, pandoc is hardcoded to use longtable. Only way to get around this is to use a python filter. (We weren't fans of this approach...)

This has been broken off from issue #1 and elaborated upon.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.