diff options
-rw-r--r-- | Master/texmf-dist/doc/latex/includernw/README.txt | 2 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/includernw/includeRnw-doc.pdf | bin | 150418 -> 156228 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/includernw/includeRnw-doc.tex | 42 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/includernw/includeRnw.sty | 76 |
4 files changed, 98 insertions, 22 deletions
diff --git a/Master/texmf-dist/doc/latex/includernw/README.txt b/Master/texmf-dist/doc/latex/includernw/README.txt index 109fe8687b9..2499aad73ea 100644 --- a/Master/texmf-dist/doc/latex/includernw/README.txt +++ b/Master/texmf-dist/doc/latex/includernw/README.txt @@ -24,7 +24,7 @@ https://github.com/Strauman/includeRnw/ Licence: -The LaTeX package includeRnw - version v0.0.2 (2018/04/29) - build 10 +The LaTeX package includeRnw - version v0.1.0 (2018/05/01) - build 11 includeRnw.sty ------------------------------------------------------------------------------------------- Copyright (c) 2018 by Andreas Storvik Strauman diff --git a/Master/texmf-dist/doc/latex/includernw/includeRnw-doc.pdf b/Master/texmf-dist/doc/latex/includernw/includeRnw-doc.pdf Binary files differindex 835e43b3a3e..a63b89d97b2 100644 --- a/Master/texmf-dist/doc/latex/includernw/includeRnw-doc.pdf +++ b/Master/texmf-dist/doc/latex/includernw/includeRnw-doc.pdf diff --git a/Master/texmf-dist/doc/latex/includernw/includeRnw-doc.tex b/Master/texmf-dist/doc/latex/includernw/includeRnw-doc.tex index 1c70a5acd92..78051eda664 100644 --- a/Master/texmf-dist/doc/latex/includernw/includeRnw-doc.tex +++ b/Master/texmf-dist/doc/latex/includernw/includeRnw-doc.tex @@ -1,5 +1,5 @@ -%% includeRnw v0.0.2b10 - 2018/04/29 -%% The LaTeX package includeRnw - version v0.0.2 (2018/04/29) build 10 +%% includeRnw v0.1.0b11 - 2018/05/01 +%% The LaTeX package includeRnw - version v0.1.0 (2018/05/01) build 11 %% Manual/Documentation for includeRnw.sty %% ------------------------------------------------------------------------------------------- %% Copyright (c) 2018 by Andreas Storvik Strauman @@ -99,7 +99,7 @@ \setlength{\parindent}{0pt} -\title{{includeRnw - manual\\ v0.0.2{\\[-0.5em]\footnotesize(build 10)}}} +\title{{includeRnw - manual\\ v0.1.0{\\[-0.5em]\footnotesize(build 11)}}} \author{Andreas Strauman} \begin{document} \maketitle @@ -119,13 +119,19 @@ If you found any bugs or want new functionality, to contribute, view the comment \end{document} \end{dispListing} +The Rnw-file: +\begin{dispListing} + <<pChunk, echo=F, cache=F >>= + read_chunk('r/.r') + @ +\end{dispListing} \begin{marker} Path to \texttt{r}-files are relative to the path of the \texttt{.Rnw}-file \end{marker} \section{Reference} \filbreak\subsection{Reference} \begin{docCommand}{includeRnw}{\oarg{irw-options}\marg{path/to/file.Rnw}} -Compiles .Rnw-files using R. Assumes that \texttt{R} can be called +\updated{v0.1.0\\2018/05/01 }Compiles .Rnw-files using R. Assumes that \texttt{R} can be called from the command line. It is optional to add the extension \texttt{.Rnw} \end{docCommand} \filbreak\subsection{Command Options} @@ -147,6 +153,30 @@ run knitr on the file if the knitted file does not exist. \optDef{noknithead}{ This option will prevent \dac{includeRnw} from building and including the knitr-preamble. } +\optDef{texenv}{ +Using the \texttt{texenv} option disables the default Rnw syntax and allows for a new one. See example below +} + The two following examples do the exact same thing:\\ + This example use standard Rnw: +\begin{dispListing} +\documentclass[a4paper]{article} +\usepackage{includeRnw} +\begin{document} + <<pChunk, echo=F, cache=F >>= + read_chunk('r/myRScript.r') + @ +\end{document} +\end{dispListing} +The following chunk uses the \refKey{texenv} option: +\begin{dispListing} +\documentclass[a4paper]{article} +\usepackage[texenv]{includeRnw} +\begin{document} + \begin{Rnw}{myChunk, echo=F, cache=F} + read_chunk('r/myRScript.r') + \end{Rnw} +\end{document} +\end{dispListing} \filbreak\subsection{User macros} The default user macro settables are \begin{dispListing} @@ -189,5 +219,9 @@ Where \dac{rnw@dir@output} is the value of the set \dac{rnwOutputDirectory} \change{Fixed wrong error message on no shell-escape} \change{Added macros for setting custom values} \change{Added \refKey{noknithead}} +\newversion{v0.1.0 2018/05/01} +\change{Added \refKey{texenv}} +\change{Fixed bug where \refKey{new} and \refKey{halt} package options didn't work} +\change{Fixed bug where \refKey{n}, \refKey{h} and \refKey{f} command options didn't work} \chlogtable \end{document} diff --git a/Master/texmf-dist/tex/latex/includernw/includeRnw.sty b/Master/texmf-dist/tex/latex/includernw/includeRnw.sty index 14cecb5b9c1..b309ba4f96d 100644 --- a/Master/texmf-dist/tex/latex/includernw/includeRnw.sty +++ b/Master/texmf-dist/tex/latex/includernw/includeRnw.sty @@ -1,5 +1,5 @@ % Source (with comments) can be found at https://github.com/Strauman/includeRnw/ -%% The LaTeX package includeRnw - version v0.0.2 (2018/04/29) - build 10 +%% The LaTeX package includeRnw - version v0.1.0 (2018/05/01) - build 11 %% includeRnw.sty %% ------------------------------------------------------------------------------------------- %% Copyright (c) 2018 by Andreas Storvik Strauman <andreas dot s dot strauman at uit dot no> @@ -13,21 +13,49 @@ %% version 2008/05/04 or later. %% This work has the LPPL maintenance status `author-maintained'. %% This work consists of all files listed in README -\ProvidesPackage{includeRnw}[2018/04/29 v0.0.2 Makes commands for including external .Rnw files.] +\ProvidesPackage{includeRnw}[2018/05/01 v0.1.0 Makes commands for including external .Rnw files.] \providecommand\rnw@loglevel{0} +\def\includeRnwVer{11 2018/05/01} \RequirePackage{pdftexcmds} \RequirePackage{kvoptions} \let\incl\input +\def\insp#1{\texttt{\string#1:\meaning#1}} +\def\inspw#1{\@latex@warning{\string#1:\meaning#1}} +\providecommand\rnw@loglevel{3} +\newcommand\@dlog[2][1]{\ifnum\rnw@loglevel>#1\relax\PackageWarning{includeRnw}{#2}{}\fi} \RequirePackage{kvoptions} \SetupKeyvalOptions{ family=includeRnw, prefix=rnw@opt@ } \DeclareBoolOption[true]{build} +\DeclareBoolOption[true]{classicenv} \DeclareComplementaryOption{halt}{build} \DeclareBoolOption[false]{new} \DeclareBoolOption[true]{knithead} \DeclareComplementaryOption{noknithead}{knithead} +\DeclareComplementaryOption{texenv}{classicenv} \ProcessKeyvalOptions*\relax +\def\rnw@knitCommand@classic{% +R -e 'library("knitr"); +knit("\rnw@dir@input/\rnw@infile@fullpath", "\rnw@dir@output/\filename@base\rnw@suffix.tex")' &> \rnw@file@knitlog +}% +\def\rnw@knitCommand@texenv{% +R -e "library('knitr'); +knit_patterns\string\$set(list( +chunk.begin = '\doublebs s*\fourbs begin\doublebs{Rnw\doublebs}\doublebs{(.+)\doublebs}', +chunk.end = '\doublebs s*\fourbs end\doublebs {Rnw\doublebs}', +inline.code = '\fourbs Sexpr\doublebs{([^{}]+)\doublebs}', +ref.chunk = '\fourbs rCode\doublebs{([^{}]+)\doublebs}' +)); +knit('\rnw@dir@input/\rnw@infile@fullpath', '\rnw@dir@output/\filename@base\rnw@suffix.tex')" &> \rnw@file@knitlog% +}% +\ifrnw@opt@classicenv\relax +\global\let\rnw@knitCommand\rnw@knitCommand@classic +\@dlog[1]{Using classic environment} +\else +\@dlog[1]{Using tex environment} +\global\let\rnw@knitCommand\rnw@knitCommand@texenv +\fi \ifrnw@opt@build\else \ifrnw@opt@new \@latex@warning{includeRnw: can't use halt and new together. Falling back to new.} @@ -39,10 +67,6 @@ \providecommand\rnw@suffix{knitted} \providecommand\rnw@file@knitlog{\rnw@dir@output/knitlog.log} \providecommand\rnw@filebase@knithead{\rnw@dir@output/knithead} -\def\insp#1{\texttt{\string#1:\meaning#1}} -\def\inspw#1{\@latex@warning{\string#1:\meaning#1}} -\providecommand\rnw@loglevel{3} -\newcommand\@dlog[2][1]{\ifnum\rnw@loglevel>#1\relax\@latex@warning{#2}\fi} \def\rnw@filename@parse#1{% \filename@parse{#1} \edef\rnw@filepath{\filename@area\filename@base} @@ -70,41 +94,59 @@ \def\rnw@include@knithead{% \IfFileExists{\rnw@filebase@knithead.tex}{}{% \@dlog[0]{Creating knithead} - \immediate\write18{echo "<<create-preamble,echo=FALSE,results='asis'>>=\string\ncat(knitr:::make_header_latex())\string\n@" > \rnw@filebase@knithead.Rnw} + \immediate\write18{% + echo "<<create-preamble,echo=FALSE,results='asis'>>=\string\ncat(knitr:::make_header_latex())\string\n@" > \rnw@filebase@knithead.Rnw +}% \immediate\write18{R -e 'library("knitr");knit("\rnw@filebase@knithead.Rnw","\rnw@filebase@knithead.tex")' >> \rnw@file@knitlog} } - \IfFileExists{\rnw@filebase@knithead.tex}{\@dlog[0]{Including knithead}\incl{\rnw@dir@output/knithead.tex}}{\PackageError{includeRnw}{Could not find knitr preamble: \rnw@dir@output/knithead.tex}{}} + \IfFileExists{\rnw@filebase@knithead.tex}{ \@dlog[0]{Including knithead} + \incl{\rnw@dir@output/knithead.tex} +}{ \PackageError{includeRnw}{Could not find knitr preamble: \rnw@dir@output/knithead.tex}{} +} } \xdef\rnw@gopt@halt{h} \xdef\rnw@gopt@force{f} -\def\ifrnw@should@knitr{ \@dlog[0]{Deciding whether to do knitting} - \let\ifrnw@local@build\ifrnw@opt@build +\def\ifrnw@should@knitr{ \@dlog[2]{Deciding whether to do knitting on \filename@base.Rnw} \newif\ifrnw@doknit \rnw@doknittrue \@dlog[2]{Decision is given option: \givenopt} - \ifnum\pdfstrcmp{\rnw@gopt@force}{\givenopt\relax}=\z@\relax\rnw@doknittrue\@dlog[2]{Focing build}\else% - \ifnum\pdfstrcmp{\rnw@gopt@halt}{\givenopt\relax}=\z@\rnw@doknitfalse\relax\else% + \ifnum\pdfstrcmp{\givenopt}{\rnw@gopt@force}=\z@\relax\rnw@doknittrue\@dlog[0]{Focing build}\else% + \@dlog[2]{Force not given} + \ifnum\pdfstrcmp{\givenopt}{\rnw@gopt@halt}=\z@\relax + \@dlog[0]{Halt option given. Not building!}% + \rnw@doknitfalse\else% + \@dlog[2]{Halt opt for command not given} \ifrnw@opt@new% + \@dlog[1]{"new" package option is given, building if \knitOutfile exists} + \IfFileExists{\knitOutfile}{\rnw@doknitfalse}{\rnw@doknittrue} \else% - \let\ifrnw@doknit\ifrnw@opt@build\relax% + \@dlog[1]{No "new" given, falling back to package option "halt"} + \ifrnw@opt@build\rnw@doknittrue\else\rnw@doknitfalse\fi \fi% \fi \fi \ifrnw@doknit -\@dlog[1]{Decided to build} } \def\rnw@purge@outdir{ \immediate\write18{rm -rf \rnw@dir@output} \immediate\write18{mkdir \rnw@dir@output} } +\def\rnw@preKnit{\newtoks\mytoks +\mytoks{\\} +\def\bs{\@backslashchar} +\def\doublebs{\bs\bs\bs\bs\bs} +\def\fourbs{\doublebs\doublebs\doublebs} +} \providecommand\rnw@execute@knitr[2][]{% \def\givenopt{#1} \rnw@filename@parse{#2} \xdef\knitOutfile{\rnw@dir@output/\filename@base\rnw@suffix.tex} \ifrnw@should@knitr + \@dlog[0]{Decided to build \filename@base.Rnw} \IfFileExists{\rnw@infile@fullpath}{ \@dlog[2]{Building \rnw@infile@fullpath\space to \rnw@dir@output/\filename@base\rnw@suffix.tex} - \immediate\write18{R -e 'library("knitr");knit("\rnw@dir@input/\rnw@infile@fullpath", "\rnw@dir@output/\filename@base\rnw@suffix.tex")' &> \rnw@file@knitlog} + \rnw@preKnit + \immediate\write18{\rnw@knitCommand} }{\@latex@error{includeRnw: Could not find file that I was asked to knit: \rnw@infile@fullpath!}{}\stop} - \else \@dlog[2]{- Skipping knit of \rnw@infile@fullpath} + \else \@dlog[0]{- Skipping knit of \rnw@infile@fullpath} \fi \IfFileExists{\knitOutfile}{% \@dlog[2]{Found \knitOutfile. Including it.} @@ -135,5 +177,5 @@ \check@output@dir \rnw@clear@knitlog \ifrnw@opt@knithead% - \rnw@include@knithead +\rnw@include@knithead \fi |