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

Suggested handling of page numbers #32

Closed
trinker opened this issue Mar 23, 2013 · 8 comments
Closed

Suggested handling of page numbers #32

trinker opened this issue Mar 23, 2013 · 8 comments

Comments

@trinker
Copy link
Contributor

@trinker trinker commented Mar 23, 2013

I love the package. I have a feature request.

It would add functionality if the package could handle a single or series of page numbers as you would have with LaTeX in that:

\cite[pp. 14-15]{cboettiger2013}

may give:

(Boettiger, 2013, pp. 14-15)
@cboettig
Copy link
Owner

@cboettig cboettig commented Mar 25, 2013

Thanks for the suggestion. Here's two options for implementing this:

I could on citep add something that works like this:

citep("10.1016/j.tpb.2013.02.004", pp="14-15")

which would generate (Schreiber & Killingback, 2013, pp. 14-15). Or I could have a more generic way to add text which would require a bit more typing:

citep("10.1016/j.tpb.2013.02.004", end="pp. 14-15")

Which would generate the same text, (Schreiber & Killingback, 2013, pp. 14-15), but could also be modified to generate parenthetical comments like (Schreiber & Killingback, 2013, provide a good overview of this approach)

I'm not sure if the latter case is useful or not.

@trinker
Copy link
Contributor Author

@trinker trinker commented Mar 25, 2013

The former appears to be more explicit to the users but perhaps the
argument could be page rather than pp Then some regexing, something
along the lines of:

page <- "14-19"

pgs <- ifelse(grepl("-", page), "pp.", "p.")
paste(pgs, page)

#or single page...

page <- "1234"

pgs <- ifelse(grepl("-", page), "pp.", "p.")
paste(pgs, page)

would format the pages correctly. I can't think of another use of the last space in a parenthetical citation (in APA style), beyond pages, thus it seems your the explicit argument of page or pages may be the most coherent. That being said I may be missing a corner case usage for the later, more general end argument. Your example use beyond pages is a point well taken and I'm not sure if the flexibility or the ease of use is a better fit for knitcitations. Perhaps both a page and end argument, though this may be making it convoluted.

@cboettig
Copy link
Owner

@cboettig cboettig commented Mar 25, 2013

Thanks for the feedback. Added this following the formatting you suggested in the most recent commit. Currently added only to parenthetical citations, let me know if such a use case also makes sense for textual citet, or whether it is more natural to add page reference in the text in that case....

@trinker
Copy link
Contributor Author

@trinker trinker commented Mar 26, 2013

Tested it out. I think you'll want to add pgs <- NULL in there in case the user doesn't provide page numbers as in:

citep <- function(x, ..., 
                  format_inline_fn = format_authoryear_p, 
                  inline_format = authoryear_p,
                  page = NULL){
  text <- citet(x, ..., 
                format_inline_fn = format_inline_fn,
                inline_format = inline_format) 
  pgs <- NULL    #add this line
  if(!is.null(page)){
    pgs <- ifelse(grepl("-", page), "pp.", "p.")
    pgs <- paste(",", pgs, page)
  }
  paste("(", text, pgs, ")", sep="", collapse=";")
}

Otherwise I get an error without page numbers.

@cboettig
Copy link
Owner

@cboettig cboettig commented Mar 26, 2013

Oh good catch, I forgot to check that. Commit fixes this and adds support for citet.

@trinker
Copy link
Contributor Author

@trinker trinker commented Apr 20, 2013

I'm closing this as this works now.

@trinker trinker closed this Apr 20, 2013
@trinker
Copy link
Contributor Author

@trinker trinker commented May 22, 2013

@carl I am soon ready to push the next version of the reports package to CRAN (waiting on slidify to go to CRAN). I realized that I am relying on the development version of knitcitations for several functions in reports and am curious when you plan to push to CRAN. You last pushed about 2 months ago.

@cboettig
Copy link
Owner

@cboettig cboettig commented May 22, 2013

Thanks for the message, now would probably be a good time to push. (I
annoyed CRAN a bit earlier when I added the features in version 0.3 and
then followed by some bug-fixes 0.3-2 etc..) Looking over this I should
put the open issues into milestones at some point to figure out what to
tackle next. If there's anything you like to see prioritized (existing
issue or not) feel free to leave a comment.

On Tue, May 21, 2013 at 9:43 PM, Tyler Rinker notifications@github.comwrote:

@carl https://github.com/Carl I am soon ready to push the next version
of the reports package to CRAN (waiting on slidify to go to CRAN). I
realized that I am relying on the development version of knitcitations for
several functions in reports and am curious when you plan to push to CRAN.
You last pushed about 2 months ago.


Reply to this email directly or view it on GitHubhttps://github.com//issues/32#issuecomment-18257219
.

Carl Boettiger
UC Santa Cruz
http://carlboettiger.info/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.