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

natbib compatible commands #12

Closed MLopez-Ibanez closed 4 years ago

MLopez-Ibanez commented 4 years ago

Thanks for this fantastic package. I have started integrating it in one of my packages but I find the syntax for the various citation commands a bit too complicated. Would it be possible to create commands using the same syntax as natbib? http://texdoc.net/texmf-dist/doc/latex/natbib/natnotes.pdf

These are quite mnemonic and widely used commands (in LaTeX), at least the \citep \citet variants.

GeoBosh commented 4 years ago

Thanks for the praise :). It is not really possible to use the natbib syntax since the Rd macros are with fixed number of arguments and don't accept optional arguments. So, in any case there should be some deviation from that syntax. There are solutions, such as enclosing all natbib arguments and parsing them all in the underlying R code but for that there needs to be a strong demand.

The syntax I chose is more akin, though not identical, to markdown and something like that was actually requested from guys in that camp.

I will leave this issue open to see what traction it will get.

MLopez-Ibanez commented 4 months ago

I solved this using: https://github.com/MLopez-Ibanez/eaf/blob/a4aa39e439ebdd8e6bb8d62ac649c691b081fe59/man/macros/macros.Rd

\newcommand{\citep}{\insertCite{#1}{eaf}}
\newcommand{\citet}{\insertCite{#1;textual}{eaf}}