From d66a575324f780018fe771d8f391d1cb011bdc9c Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 29 Apr 2018 21:47:49 +0000 Subject: includernw (29apr18) git-svn-id: svn://tug.org/texlive/trunk@47484 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/includernw/README.txt | 40 +++++ .../doc/latex/includernw/includeRnw-doc.pdf | Bin 0 -> 150418 bytes .../doc/latex/includernw/includeRnw-doc.tex | 193 +++++++++++++++++++++ .../texmf-dist/tex/latex/includernw/includeRnw.sty | 139 +++++++++++++++ 4 files changed, 372 insertions(+) create mode 100644 Master/texmf-dist/doc/latex/includernw/README.txt create mode 100644 Master/texmf-dist/doc/latex/includernw/includeRnw-doc.pdf create mode 100644 Master/texmf-dist/doc/latex/includernw/includeRnw-doc.tex create mode 100644 Master/texmf-dist/tex/latex/includernw/includeRnw.sty (limited to 'Master/texmf-dist') diff --git a/Master/texmf-dist/doc/latex/includernw/README.txt b/Master/texmf-dist/doc/latex/includernw/README.txt new file mode 100644 index 00000000000..109fe8687b9 --- /dev/null +++ b/Master/texmf-dist/doc/latex/includernw/README.txt @@ -0,0 +1,40 @@ +includeRnw: +Makes commands for including external .Rnw files. + +├── README.txt +├── includeRnw-doc.pdf +├── includeRnw-doc.tex +└── includeRnw.sty + +Not tested on Windows! + +Quick start: + +\documentclass{article} +\usepackage{includeRnw} +\begin{document} + \includeRnw{path/to/my.Rnw} +\end{document} + + +Author: Storvik Strauman, Andreas + +For bug report, inquires, contributed or anything else: +https://github.com/Strauman/includeRnw/ + +Licence: + +The LaTeX package includeRnw - version v0.0.2 (2018/04/29) - build 10 +includeRnw.sty +------------------------------------------------------------------------------------------- +Copyright (c) 2018 by Andreas Storvik Strauman +------------------------------------------------------------------------------------------- +This work may be distributed and/or modified under the +conditions of the LaTeX Project Public License, either version 1.3c +of this license or (at your option) any later version. +The latest version of this license is in + http://www.latex-project.org/lppl.txt +and version 1.3c or later is part of all distributions of LaTeX +version 2008/05/04 or later. +This work has the LPPL maintenance status `author-maintained'. +This work consists of all files listed in README.txt diff --git a/Master/texmf-dist/doc/latex/includernw/includeRnw-doc.pdf b/Master/texmf-dist/doc/latex/includernw/includeRnw-doc.pdf new file mode 100644 index 00000000000..835e43b3a3e Binary files /dev/null and b/Master/texmf-dist/doc/latex/includernw/includeRnw-doc.pdf differ diff --git a/Master/texmf-dist/doc/latex/includernw/includeRnw-doc.tex b/Master/texmf-dist/doc/latex/includernw/includeRnw-doc.tex new file mode 100644 index 00000000000..1c70a5acd92 --- /dev/null +++ b/Master/texmf-dist/doc/latex/includernw/includeRnw-doc.tex @@ -0,0 +1,193 @@ +%% includeRnw v0.0.2b10 - 2018/04/29 +%% The LaTeX package includeRnw - version v0.0.2 (2018/04/29) build 10 +%% Manual/Documentation for includeRnw.sty +%% ------------------------------------------------------------------------------------------- +%% Copyright (c) 2018 by Andreas Storvik Strauman +%% ------------------------------------------------------------------------------------------- +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3c +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3c or later is part of all distributions of LaTeX +%% version 2008/05/04 or later. +%% This work has the LPPL maintenance status `author-maintained'. +%% This work consists of all files listed in README.txt +\documentclass[a4paper]{article} +\usepackage[all]{tcolorbox} +\usepackage{needspace} +\usepackage{tabularx} +\usepackage{geometry} +\makeatletter +\def\input@path{{../../docs/}} +\lstdefinestyle{mydocumentation}{style=tcbdocumentation, + classoffset=0, + texcsstyle=*\color{blue}, + moretexcs={arrayrulecolor,draw,includegraphics,ifthenelse,isodd,lipsum,path,pgfkeysalso}, + classoffset=1, + moretexcs={% core + includeRnw + }, + texcsstyle=*\color{Definition}\bfseries, + classoffset=0,% restore default + } +\newtcolorbox{marker}[1][]{enhanced, + before skip=2mm,after skip=3mm, + boxrule=0.4pt,left=5mm,right=2mm,top=1mm,bottom=1mm, + colback=yellow!50, + colframe=yellow!20!black, + sharp corners,rounded corners=southeast,arc is angular,arc=3mm, + underlay={% + \path[fill=tcbcol@back!80!black] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2); + \path[draw=tcbcol@frame,shorten <=-0.05mm,shorten >=-0.05mm] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2); + \path[fill=yellow!50!black,draw=none] (interior.south west) rectangle node[white]{\Huge\bfseries !} ([xshift=4mm]interior.north west); + }, + drop fuzzy shadow,#1} + \def\l@macro#1#2{#1\hfill\newline} +\newcommand\macrotable{\hypersetup{linkcolor=black}\@starttoc{mac}\hypersetup{linkcolor=Definition}} +\newcommand\gh[1]{\href{#1}{https://github.com/#1}} +% --- CHANGELOG TABLE --- % +\newcommand*\l@version[2]{% + \ifnum \c@tocdepth >\z@ + \addpenalty\@secpenalty + \addvspace{1.0em \@plus\p@}% + \setlength\@tempdima{1.5em}% + \begingroup + \parindent \z@ \rightskip \@pnumwidth + \parfillskip -\@pnumwidth + \leavevmode \bfseries + \advance\leftskip\@tempdima + \hskip -\leftskip + #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{}\par + \endgroup + \fi} + \newcommand*\l@change[2]{% + \addvspace{0.5em \@plus\p@}% + \leftskip1em--\hspace{0.5em}\begin{minipage}{0.5\textwidth}#1\end{minipage}\hfill% + \begin{minipage}{0.3\textwidth}#2\end{minipage}\par% + } + +\newcommand\chlogtable{\begin{NoHyper}\@starttoc{chlog}\hypersetup{final}\end{NoHyper}} +\def\newversion#1{\addcontentsline{chlog}{version}{#1}} +\newcommand\change[2][]{\addtocontents{chlog}{\protect\contentsline{change}{#2}{#1}{section.\thepage}}} +% --- /CHANGELOG TABLE --- % + +\let\oldTOC\tableofcontents +\renewcommand\tableofcontents{\hypersetup{linkcolor=black}\oldTOC\hypersetup{linkcolor=Definition}} +\reversemarginpar +\def\updated#1{\tcbdocmarginnote{\bfseries{\color{blue}U}#1}} +\def\defnew#1{\tcbdocmarginnote{\bfseries{\color{green}N}#1}} + +\let\dac\docAuxCommand +\def\mdac#1{\docAuxCommand{\expandafter\@gobble\string#1}} + +\makeatother + +\long\def\keyDef#1#2#3#4{\begin{docKey}{#1}{=\meta{#2}}{\meta{default}=#3}#4\end{docKey}} +\long\def\optDef#1#2{\begin{docKey*}{#1}{}{}#2\end{docKey*}} +\tcbset{documentation listing style=mydocumentation} +% Magenta HREF style +\let\oldhref\href +\gdef\href#1#2{{\color{magenta}\oldhref{#1}{#2}}} +\tcbset{documentation listing style=mydocumentation,/tcb/color hyperlink=Definition} +\hypersetup{colorlinks=true} +% Give section some space +\let\oldsection\section +\gdef\section{\needspace{0.3\paperheight}\oldsection} +\let\oldsubsection\subsection +\gdef\subsection{\needspace{0.2\paperheight}\oldsubsection} + + +\setlength{\parindent}{0pt} +\title{{includeRnw - manual\\ v0.0.2{\\[-0.5em]\footnotesize(build 10)}}} +\author{Andreas Strauman} +\begin{document} +\maketitle +This package is for including \texttt{.Rnw}-files in normal \texttt{.tex}-files. +It invokes the command \texttt{R} from your command line.\\ + +If you found any bugs or want new functionality, to contribute, view the commented source, get latest version of this package or get in touch with me, you can do all of that at\\\url{https://github.com/Strauman/includeRnw/}. If you have questions of functionality, kindly direct them to the community\\ \url{http://tex.stackexchange.com}. The author is active on this site regularly. + +\tableofcontents +\clearpage +\section{Quick start} +\begin{dispListing} + \documentclass{article} + \usepackage{includeRnw} + \begin{document} + \includeRnw{path/to/my.Rnw} + \end{document} +\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 +from the command line. It is optional to add the extension \texttt{.Rnw} +\end{docCommand} +\filbreak\subsection{Command Options} +Options to use with \refCom{includeRnw} +\optDef{h}{Use the \refKey{h} to prevent \dac{includeRnw} from +actually knitting the file, but only include the knitted \texttt{.tex} file} +\optDef{f}{\refKey{f} forces \dac{includeRnw} to actually knitting the file no matter, +what (as long as it exists).} +\filbreak\subsection{Package Options} +\dac{usepackage}[\oarg{options}] where the \meta{options} are:\\ +\optDef{halt}{If you do \dac{usepackage}[halt]\brackets{includeRnw}, +then \dac{includeRnw}\{my/file.Rnw\} will \emph{not} run knitr on it. +However, if the knitted file exists, it will include this. You can +override this with the f-option in the \refCom{includeRnw}: +\dac{includeRnw}[f]\brackets{my/file.Rnw}} +\optDef{new}{This option would make the \refCom{includeRnw} only +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. +} +\filbreak\subsection{User macros} + The default user macro settables are +\begin{dispListing} +\rnwInputDirectory{.} +\rnwKnittedSuffix{knitted} +\rnwKnitlogFile{\rnw@dir@output/knitlog.log} +\rnwKnitheadName{\rnw@dir@output/knithead} +\end{dispListing} +Where \dac{rnw@dir@output} is the value of the set \dac{rnwOutputDirectory} +\begin{docCommand}{rnwInputDirectory}{\marg{directory}} +\defnew{v0.0.2\\2018/04/28 } This command sets what directory \dac{includeRnw} will be using. If you e.g. + have all the Rnw-files inside a directory called \texttt{myRnws} then + \dac{rnwInputDirectory}\brackets{myRnws} would fix this. +\end{docCommand} +\begin{docCommand}{rnwKnittedSuffix}{\marg{text}} +\defnew{v0.0.2\\2018/04/28 } Set the default suffix of the filename of the knitted output +\end{docCommand} +\begin{docCommand}{rnwKnitlogFile}{\marg{filename}} +\defnew{v0.0.2\\2018/04/28 } Sets the filename of the log output by knitr. +\end{docCommand} +\begin{docCommand}{rnwKnitheadName}{\marg{filename}} +\defnew{v0.0.2\\2018/04/28 } Sets the filename of the preamble generated by knitr. +\end{docCommand} +\filbreak\subsection{List of all macros} + + \addcontentsline{mac}{macro}{\refCom{includeRnw}}{} +\addcontentsline{mac}{macro}{\refCom{rnwInputDirectory}}{} +\addcontentsline{mac}{macro}{\refCom{rnwKnitheadName}}{} +\addcontentsline{mac}{macro}{\refCom{rnwKnitlogFile}}{} +\addcontentsline{mac}{macro}{\refCom{rnwKnittedSuffix}}{} + + \macrotable + + +% \newgeometry{lmargin=0.7cm} +\section{Changelog} +\newversion{v0.0.1 2018/04/20} +\change{Created the package} +\newversion{v0.0.2 2018/04/28} +\change{Fixed wrong error message on no shell-escape} +\change{Added macros for setting custom values} +\change{Added \refKey{noknithead}} +\chlogtable + \end{document} diff --git a/Master/texmf-dist/tex/latex/includernw/includeRnw.sty b/Master/texmf-dist/tex/latex/includernw/includeRnw.sty new file mode 100644 index 00000000000..14cecb5b9c1 --- /dev/null +++ b/Master/texmf-dist/tex/latex/includernw/includeRnw.sty @@ -0,0 +1,139 @@ +% 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 +%% includeRnw.sty +%% ------------------------------------------------------------------------------------------- +%% Copyright (c) 2018 by Andreas Storvik Strauman +%% ------------------------------------------------------------------------------------------- +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3c +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3c or later is part of all distributions of LaTeX +%% 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.] +\providecommand\rnw@loglevel{0} +\RequirePackage{pdftexcmds} +\RequirePackage{kvoptions} +\let\incl\input +\RequirePackage{kvoptions} +\SetupKeyvalOptions{ family=includeRnw, + prefix=rnw@opt@ +} +\DeclareBoolOption[true]{build} +\DeclareComplementaryOption{halt}{build} +\DeclareBoolOption[false]{new} +\DeclareBoolOption[true]{knithead} +\DeclareComplementaryOption{noknithead}{knithead} +\ProcessKeyvalOptions*\relax +\ifrnw@opt@build\else + \ifrnw@opt@new + \@latex@warning{includeRnw: can't use halt and new together. Falling back to new.} + \rnw@opt@haltfalse + \fi +\fi +\providecommand\rnw@dir@input{.} +\providecommand\rnw@dir@output{./knitrout} +\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} + \edef\rnw@filebase{\filename@base} + \edef\rnw@fileext{\ifx\filename@ext\relax Rnw\else\filename@ext\fi} + \edef\rnw@infile@fullpath{\filename@area\filename@base.\filename@ext} +} +\def\rnw@clear@knitlog{% +\immediate\write18{echo "" > \rnw@file@knitlog} +} +\def\rnw@check@ouput@file{\rnw@dir@output/.includeRnwShellEscapeCheck} +\def\check@shell@escape{% + \ifcase\pdf@shellescape% + \PackageError{includeRnw}{\string\includeRnw\space requires --shell-escape}{}\stop\or% + \message{Shell escape test passed}\or% + \PackageError{includeRnw}{\string\includeRnw\space requires --shell-escape. Current is restricted shell escape}{}\stop\fi% +} +\def\check@output@dir{% + \immediate\write18{touch \rnw@check@ouput@file} + \IfFileExists{\rnw@check@ouput@file}{}{% + \immediate\write18{mkdir \rnw@dir@output} +} + \immediate\write18{rm \rnw@check@ouput@file} +} +\def\rnw@include@knithead{% + \IfFileExists{\rnw@filebase@knithead.tex}{}{% + \@dlog[0]{Creating knithead} + \immediate\write18{echo "<>=\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}{}} +} +\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 + \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% + \ifrnw@opt@new% + \else% + \let\ifrnw@doknit\ifrnw@opt@build\relax% + \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} +} +\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 + \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} +}{\@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} + \fi + \IfFileExists{\knitOutfile}{% + \@dlog[2]{Found \knitOutfile. Including it.} + \incl{\knitOutfile} +}{% + \PackageError{includeRnw}{Couldn't find knitted file: \knitOutfile}{} +} +} +\newcommand\rnw@settable[3][]{% +\edef\reserved@R{\expandafter\@gobble\string #2}% +\@ifundefined\reserved@R% + {% + \gdef#2##1{\gdef#3{##1}#1} +}% + {% + \@ifundefined{no\reserved@R}{ \@latex@error{includeRnw: Tried to define \@backslashchar \reserved@R \space, but it's already defined. \MessageBreak If you don't need the command \@backslashchar \reserved@R \space, then just define \string\no\reserved@R\space before you include the includeRnw package: \string\def\string\no\reserved@R{}}{}\stop +}{ \@latex@warning{\@backslashchar\reserved@R is not defined by includeRnw since it was already defined someewhere else. Continuing since \string\no\reserved@R is defined.} +} +}% +} +\rnw@settable\rnwInputDirectory\rnw@dir@input +\rnw@settable\rnwKnittedSuffix\rnw@suffix +\rnw@settable\rnwKnitlogFile\rnw@file@knitlog +\rnw@settable\rnwKnitheadName\rnw@filebase@knithead +\let\includeRnw\rnw@execute@knitr +\let\purgeOutDir\rnw@purge@outdir +\check@shell@escape +\check@output@dir +\rnw@clear@knitlog +\ifrnw@opt@knithead% + \rnw@include@knithead +\fi -- cgit v1.2.3