Re: [R-pkg-devel] Vignettes from LaTeX files.
Thanks Dirk. Sorry for being so slow to express my thanks. I've been, uh, distracted. Have not yet tried out your demo; I will shortly. Thanks again. cheers, Rolf -- Honorary Research Fellow Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 __ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel
Re: [R-pkg-devel] Vignettes from LaTeX files.
On 06/03/2021 9:12 a.m., Dirk Eddelbuettel wrote: On 5 March 2021 at 15:41, Duncan Murdoch wrote: | On 05/03/2021 2:40 p.m., Henrik Bengtsson wrote: | > Thank you. Glad to hear it's useful. | > | > This plain TeX/LaTeX vignette engine is implemented using base R. If | > someone is willing to drive the efforts, I think it's not too much | > work to refactor it and propose it for base R itself, where I think it | > belongs, | | What is your reasoning for this? As a former R Core member, I would say | the reasons for something to be added to base R are: | | - it's generally useful | - it doesn't have a lot of dependencies | - it doesn't work as well in a contributed package | | The first two conditions seem to be met, but what's wrong with leaving | it in R.rsp? Would something in base R be simplified by having this there? It feels like this is about the third time in a decade+ I have seen you two discuss the same issue. Henrik advocates a fine technical solution from his r.rsp package, you point out that there is benefit to keeping base R smaller, and solutions in add-on packages. I don't really see it as a discussion. I believe you that it's (at least) the third time I've repeated the point that base R inclusions need more justification than "I think it belongs there" (not only to Henrik), but I don't recall the discussion ever continuing beyond that. Duncan Murdoch __ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel
Re: [R-pkg-devel] Vignettes from LaTeX files.
On 7 March 2021 at 12:54, Rolf Turner wrote: | Dirk Eddelbuettel wrote: | By "in base R" do you mean that one can do this *without* invoking | the R.rsp package? Exactly. Zero added dependencies. | What I understand you to be saying is that you can add four or five | lines to a *.tex file in your vignettes directory (or does the file | need to have a .Rnw extension?) and then the vignette will get built, | when you build the package, without any recourse to the R.rsp package. | (And there is then no need for any reference to R.rsp in your | DESCRIPTION file.) | | Is this correct? | | Can you be more explicit about the "four or five lines"? See below. | If my understanding is correct, it would be nice to see this all set | out in simple terms in WRE. Currently what is said in WRE is over my | head, and think would be over the heads of many of us ordinary mortals. Here is concrete example of a minimal latex file (I had in /tmp from showing a colleague newer to plain latex the effects of setting/not-setting \date{}) \documentclass[12pt]{article} \author{Lennon and McCartney} \date{The Sixties} \title{Lots of stuff} \begin{document} \maketitle \end{document} As you can see, no bells, no whistles, no limits. You could add whatever you wanted. Now as probably documented in several places, used in numerous examples and many packages, _all it takes_ is adding four lines as a Sweave vignette only needs the vignette headers: \documentclass[12pt]{article} \author{Lennon and McCartney} \date{The Sixties} \title{Lots of stuff} %\VignetteIndexEntry{Classics} %\VignetteKeywords{lennon, mccartney, harrison, starr} %\VignettePackage{musicology} %\VignetteEncoding{UTF-8} \begin{document} \maketitle \end{document} Just how you can 'pdflatex demo.tex' (if the former is saved as 'demo.tex') you can 'sweave demo.Rnw' (if the latter is saved as 'demo.tex') where sweave is the helper script below wrapping what would happen inside a package build. And that's all there is. Give it a try. Should also work if thrown into a package. Dirk PS sweave script below. It's old and local... I should add xdg-open at the end. #!/bin/bash -e function errorexit () { echo "Error: $1" exit 1 } function filetest () { if [ ! -f $1 ]; then errorexit "File $1 not found" fi return 0 } if [ "$#" -lt 1 ]; then errorexit "Need to specify argument file" fi BASENAME=$(basename $1 .Rnw) RNWFILE=$BASENAME.Rnw filetest $RNWFILE echo "library(tools); Sweave(\"$RNWFILE\")" \ | R --no-save --no-restore --slave LATEXFILE=$BASENAME.tex filetest $LATEXFILE && pdflatex $LATEXFILE PDFFILE=$BASENAME.pdf #filetest $PDFFILE && acroread $PDFFILE & #filetest $PDFFILE && xpdf $PDFFILE & #filetest $PDFFILE && kpdf $PDFFILE & -- https://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org __ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel
Re: [R-pkg-devel] Vignettes from LaTeX files.
On Sat, 6 Mar 2021 08:12:40 -0600 Dirk Eddelbuettel wrote: > All the while we all carry on and just slap the four or five lines > onto the file make it an Sweave vignette _without any executed code_ > which works in base R today as a proxy for pure LaTeX, just as it has > for 25 or so years. By "in base R" do you mean that one can do this *without* invoking the R.rsp package? What I understand you to be saying is that you can add four or five lines to a *.tex file in your vignettes directory (or does the file need to have a .Rnw extension?) and then the vignette will get built, when you build the package, without any recourse to the R.rsp package. (And there is then no need for any reference to R.rsp in your DESCRIPTION file.) Is this correct? Can you be more explicit about the "four or five lines"? If my understanding is correct, it would be nice to see this all set out in simple terms in WRE. Currently what is said in WRE is over my head, and think would be over the heads of many of us ordinary mortals. > Or do as some of us do and follow Mark's trick [1] of including a > pre-made pdf inside an even more minimal Rnw file for the Sweave > driver. Works great with any pdf: pure LaTeX, LaTeX from (R)Markdown, > ... > > Dirk > > [1] > https://www.markvanderloo.eu/yaRb/2019/01/11/add-a-static-pdf-vignette-to-an-r-package/ > It would also be nice to see Mark's admirably lucid instructions included, or at least pointed to, in WRE. cheers, Rolf -- Honorary Research Fellow Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 __ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel
Re: [R-pkg-devel] Vignettes from LaTeX files.
On 5 March 2021 at 15:41, Duncan Murdoch wrote: | On 05/03/2021 2:40 p.m., Henrik Bengtsson wrote: | > Thank you. Glad to hear it's useful. | > | > This plain TeX/LaTeX vignette engine is implemented using base R. If | > someone is willing to drive the efforts, I think it's not too much | > work to refactor it and propose it for base R itself, where I think it | > belongs, | | What is your reasoning for this? As a former R Core member, I would say | the reasons for something to be added to base R are: | | - it's generally useful | - it doesn't have a lot of dependencies | - it doesn't work as well in a contributed package | | The first two conditions seem to be met, but what's wrong with leaving | it in R.rsp? Would something in base R be simplified by having this there? It feels like this is about the third time in a decade+ I have seen you two discuss the same issue. Henrik advocates a fine technical solution from his r.rsp package, you point out that there is benefit to keeping base R smaller, and solutions in add-on packages. All the while we all carry on and just slap the four or five lines onto the file make it an Sweave vignette _without any executed code_ which works in base R today as a proxy for pure LaTeX, just as it has for 25 or so years. Or do as some of us do and follow Mark's trick [1] of including a pre-made pdf inside an even more minimal Rnw file for the Sweave driver. Works great with any pdf: pure LaTeX, LaTeX from (R)Markdown, ... Dirk [1] https://www.markvanderloo.eu/yaRb/2019/01/11/add-a-static-pdf-vignette-to-an-r-package/ -- https://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org __ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel
Re: [R-pkg-devel] Vignettes from LaTeX files.
On 05/03/2021 2:40 p.m., Henrik Bengtsson wrote: Thank you. Glad to hear it's useful. This plain TeX/LaTeX vignette engine is implemented using base R. If someone is willing to drive the efforts, I think it's not too much work to refactor it and propose it for base R itself, where I think it belongs, What is your reasoning for this? As a former R Core member, I would say the reasons for something to be added to base R are: - it's generally useful - it doesn't have a lot of dependencies - it doesn't work as well in a contributed package The first two conditions seem to be met, but what's wrong with leaving it in R.rsp? Would something in base R be simplified by having this there? Duncan e.g. in the 'utils' package where Sweave lives, or in 'tools' where tools::texi2dvi() lives. The vignette engine could be called 'utils::tex', e.g. %\VignetteEngine{utils::tex}. To me it meets the standards for reproducible documentation from source, although, obviously there's no 'tangle':d code output. If we want the latter, we're getting into literate programming, and we already have several vignette engines for that. Just a thought, Henrik On Thu, Mar 4, 2021 at 7:20 PM Rolf Turner wrote: I have now tried out building vignettes from plain LaTeX source, following the admirably lucid instructions provided by Henrik Bengtsson in: https://cran.r-project.org/web/packages/R.rsp/vignettes/R_packages-LaTeX_vignettes.pdf It all went unbelievably smoothly; no problems whatever. I am deeply grateful to Henrik. cheers, Rolf Turner -- Honorary Research Fellow Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 __ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel __ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel
Re: [R-pkg-devel] Vignettes from LaTeX files.
Thank you. Glad to hear it's useful. This plain TeX/LaTeX vignette engine is implemented using base R. If someone is willing to drive the efforts, I think it's not too much work to refactor it and propose it for base R itself, where I think it belongs, e.g. in the 'utils' package where Sweave lives, or in 'tools' where tools::texi2dvi() lives. The vignette engine could be called 'utils::tex', e.g. %\VignetteEngine{utils::tex}. To me it meets the standards for reproducible documentation from source, although, obviously there's no 'tangle':d code output. If we want the latter, we're getting into literate programming, and we already have several vignette engines for that. Just a thought, Henrik On Thu, Mar 4, 2021 at 7:20 PM Rolf Turner wrote: > > > > I have now tried out building vignettes from plain LaTeX source, > following the admirably lucid instructions provided by Henrik Bengtsson > in: > > > https://cran.r-project.org/web/packages/R.rsp/vignettes/R_packages-LaTeX_vignettes.pdf > > It all went unbelievably smoothly; no problems whatever. > > I am deeply grateful to Henrik. > > cheers, > > Rolf Turner > > -- > Honorary Research Fellow > Department of Statistics > University of Auckland > Phone: +64-9-373-7599 ext. 88276 > __ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel