GeoBosh / Rdpack

R package Rdpack provides functions and macros facilitating writing and management of R documentation.
https://geobosh.github.io/Rdpack/
28 stars 6 forks source link

Feature request: citation style #5

Closed jhal324 closed 6 years ago

jhal324 commented 6 years ago

In help files Rdpack will automatically configure author to an abbreviated style, for example: Boshnakov GN (2018) Rdpack: Update and Manipulate Rd Documentation Objects. A useful feature would be the ability to change this style as is possible in LaTeX. Using again the example above, a common citation style would include the author's first name: Georgi N. Boshnakov (2018) Rdpack: Update and Manipulate Rd Documentation Objects.

GeoBosh commented 6 years ago

This is not currently implemented but is supported by the underlying functions, so can be implemented. This is already in my TODO items to equip \insertAllCited{} with a non-empty argument style.

If a style is made available, then it might be desirable to set it package-wide. One way to do this would be for a package requiring a specific style to export a variable that identifies it.

Further comments on this would be helpful.

GeoBosh commented 6 years ago

A draft implementation is in branch bibstyles. Not document yet, but to cause all list of references produced by \insertAllCited in a package to appear with full names, add .onLoad() function to your package. If you don't have .onLoad(), just copy the following definition:

.onLoad <- function(lib, pkg){
    Rdpack::Rdpack_bibstyles(package = pkg, authors = "LongNames")
    invisible(NULL)
}

If you already have .onLoad(), add the line containing the Rdpack::Rdpack_bibstyles call to it.

Comments and further suggestions are very welcome.

jhal324 commented 6 years ago

This fix is precisely the kind of thing I was looking for. Thank you for the fix!

Attractively, this fix doesn't require an argument in \insertAllCited{} - which would be a little unnecessary if the command was needed repeatedly. Setting the global bibstyle is a much neater approach.

One suggestion I would make would be for a similar change to be enforced to \insertRef{tag}{pkg}. If both \insertAllCited{} and \insertRef{tag}{pkg} are used within a package, it makes for an inconsistent style. Naturally, this fix has been created to deal with my issue, but as more styles could be added, perhaps a naming system more in line with LaTeX would be appreciated by the general user.

GeoBosh commented 6 years ago

I have now added support for long names in \insertRef. This will become version 0.8-0 after further testing and documenting the new features.

GeoBosh commented 6 years ago

The feature is now merged in the main branch of Rdpack and is available from version 0.8-0.