texlive[47557] Master/texmf-dist: includernw (1may18)
commits+karl at tug.org
commits+karl at tug.org
Tue May 1 23:14:32 CEST 2018
Revision: 47557
http://tug.org/svn/texlive?view=revision&revision=47557
Author: karl
Date: 2018-05-01 23:14:31 +0200 (Tue, 01 May 2018)
Log Message:
-----------
includernw (1may18)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/latex/includernw/README.txt
trunk/Master/texmf-dist/doc/latex/includernw/includeRnw-doc.pdf
trunk/Master/texmf-dist/doc/latex/includernw/includeRnw-doc.tex
trunk/Master/texmf-dist/tex/latex/includernw/includeRnw.sty
Modified: trunk/Master/texmf-dist/doc/latex/includernw/README.txt
===================================================================
--- trunk/Master/texmf-dist/doc/latex/includernw/README.txt 2018-05-01 18:25:13 UTC (rev 47556)
+++ trunk/Master/texmf-dist/doc/latex/includernw/README.txt 2018-05-01 21:14:31 UTC (rev 47557)
@@ -24,7 +24,7 @@
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
Modified: trunk/Master/texmf-dist/doc/latex/includernw/includeRnw-doc.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/doc/latex/includernw/includeRnw-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/includernw/includeRnw-doc.tex 2018-05-01 18:25:13 UTC (rev 47556)
+++ trunk/Master/texmf-dist/doc/latex/includernw/includeRnw-doc.tex 2018-05-01 21:14:31 UTC (rev 47557)
@@ -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,6 +119,12 @@
\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}
@@ -125,7 +131,7 @@
\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 @@
\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 @@
\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}
Modified: trunk/Master/texmf-dist/tex/latex/includernw/includeRnw.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/includernw/includeRnw.sty 2018-05-01 18:25:13 UTC (rev 47556)
+++ trunk/Master/texmf-dist/tex/latex/includernw/includeRnw.sty 2018-05-01 21:14:31 UTC (rev 47557)
@@ -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 at 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 at warning{\string#1:\meaning#1}}
+\providecommand\rnw at loglevel{3}
+\newcommand\@dlog[2][1]{\ifnum\rnw at loglevel>#1\relax\PackageWarning{includeRnw}{#2}{}\fi}
\RequirePackage{kvoptions}
\SetupKeyvalOptions{ family=includeRnw,
prefix=rnw at 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 at knitCommand@classic{%
+R -e 'library("knitr");
+knit("\rnw at dir@input/\rnw at infile@fullpath", "\rnw at dir@output/\filename at base\rnw at suffix.tex")' &> \rnw at file@knitlog
+}%
+\def\rnw at 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 at dir@input/\rnw at infile@fullpath', '\rnw at dir@output/\filename at base\rnw at suffix.tex')" &> \rnw at file@knitlog%
+}%
+\ifrnw at opt@classicenv\relax
+\global\let\rnw at knitCommand\rnw at knitCommand@classic
+\@dlog[1]{Using classic environment}
+\else
+\@dlog[1]{Using tex environment}
+\global\let\rnw at knitCommand\rnw at knitCommand@texenv
+\fi
\ifrnw at opt@build\else
\ifrnw at opt@new
\@latex at warning{includeRnw: can't use halt and new together. Falling back to new.}
@@ -39,10 +67,6 @@
\providecommand\rnw at suffix{knitted}
\providecommand\rnw at file@knitlog{\rnw at dir@output/knitlog.log}
\providecommand\rnw at filebase@knithead{\rnw at dir@output/knithead}
-\def\insp#1{\texttt{\string#1:\meaning#1}}
-\def\inspw#1{\@latex at warning{\string#1:\meaning#1}}
-\providecommand\rnw at loglevel{3}
-\newcommand\@dlog[2][1]{\ifnum\rnw at loglevel>#1\relax\@latex at warning{#2}\fi}
\def\rnw at filename@parse#1{%
\filename at parse{#1}
\edef\rnw at filepath{\filename at area\filename at base}
@@ -70,41 +94,59 @@
\def\rnw at include@knithead{%
\IfFileExists{\rnw at 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 at filebase@knithead.Rnw}
+ \immediate\write18{%
+ echo "<<create-preamble,echo=FALSE,results='asis'>>=\string\ncat(knitr:::make_header_latex())\string\n@" > \rnw at filebase@knithead.Rnw
+}%
\immediate\write18{R -e 'library("knitr");knit("\rnw at filebase@knithead.Rnw","\rnw at filebase@knithead.tex")' >> \rnw at file@knitlog}
}
- \IfFileExists{\rnw at filebase@knithead.tex}{\@dlog[0]{Including knithead}\incl{\rnw at dir@output/knithead.tex}}{\PackageError{includeRnw}{Could not find knitr preamble: \rnw at dir@output/knithead.tex}{}}
+ \IfFileExists{\rnw at filebase@knithead.tex}{ \@dlog[0]{Including knithead}
+ \incl{\rnw at dir@output/knithead.tex}
+}{ \PackageError{includeRnw}{Could not find knitr preamble: \rnw at dir@output/knithead.tex}{}
}
+}
\xdef\rnw at gopt@halt{h}
\xdef\rnw at gopt@force{f}
-\def\ifrnw at should@knitr{ \@dlog[0]{Deciding whether to do knitting}
- \let\ifrnw at local@build\ifrnw at opt@build
+\def\ifrnw at should@knitr{ \@dlog[2]{Deciding whether to do knitting on \filename at base.Rnw}
\newif\ifrnw at doknit
\rnw at doknittrue
\@dlog[2]{Decision is given option: \givenopt}
- \ifnum\pdfstrcmp{\rnw at gopt@force}{\givenopt\relax}=\z@\relax\rnw at doknittrue\@dlog[2]{Focing build}\else%
- \ifnum\pdfstrcmp{\rnw at gopt@halt}{\givenopt\relax}=\z@\rnw at doknitfalse\relax\else%
+ \ifnum\pdfstrcmp{\givenopt}{\rnw at gopt@force}=\z@\relax\rnw at doknittrue\@dlog[0]{Focing build}\else%
+ \@dlog[2]{Force not given}
+ \ifnum\pdfstrcmp{\givenopt}{\rnw at gopt@halt}=\z@\relax
+ \@dlog[0]{Halt option given. Not building!}%
+ \rnw at doknitfalse\else%
+ \@dlog[2]{Halt opt for command not given}
\ifrnw at opt@new%
+ \@dlog[1]{"new" package option is given, building if \knitOutfile exists}
+ \IfFileExists{\knitOutfile}{\rnw at doknitfalse}{\rnw at doknittrue}
\else%
- \let\ifrnw at doknit\ifrnw at opt@build\relax%
+ \@dlog[1]{No "new" given, falling back to package option "halt"}
+ \ifrnw at opt@build\rnw at doknittrue\else\rnw at doknitfalse\fi
\fi%
\fi
\fi
\ifrnw at doknit
-\@dlog[1]{Decided to build}
}
\def\rnw at purge@outdir{ \immediate\write18{rm -rf \rnw at dir@output}
\immediate\write18{mkdir \rnw at dir@output}
}
+\def\rnw at preKnit{\newtoks\mytoks
+\mytoks{\\}
+\def\bs{\@backslashchar}
+\def\doublebs{\bs\bs\bs\bs\bs}
+\def\fourbs{\doublebs\doublebs\doublebs}
+}
\providecommand\rnw at execute@knitr[2][]{%
\def\givenopt{#1}
\rnw at filename@parse{#2}
\xdef\knitOutfile{\rnw at dir@output/\filename at base\rnw at suffix.tex}
\ifrnw at should@knitr
+ \@dlog[0]{Decided to build \filename at base.Rnw}
\IfFileExists{\rnw at infile@fullpath}{ \@dlog[2]{Building \rnw at infile@fullpath\space to \rnw at dir@output/\filename at base\rnw at suffix.tex}
- \immediate\write18{R -e 'library("knitr");knit("\rnw at dir@input/\rnw at infile@fullpath", "\rnw at dir@output/\filename at base\rnw at suffix.tex")' &> \rnw at file@knitlog}
+ \rnw at preKnit
+ \immediate\write18{\rnw at knitCommand}
}{\@latex at error{includeRnw: Could not find file that I was asked to knit: \rnw at infile@fullpath!}{}\stop}
- \else \@dlog[2]{- Skipping knit of \rnw at infile@fullpath}
+ \else \@dlog[0]{- Skipping knit of \rnw at infile@fullpath}
\fi
\IfFileExists{\knitOutfile}{%
\@dlog[2]{Found \knitOutfile. Including it.}
@@ -135,5 +177,5 @@
\check at output@dir
\rnw at clear@knitlog
\ifrnw at opt@knithead%
- \rnw at include@knithead
+\rnw at include@knithead
\fi
More information about the tex-live-commits
mailing list