%% 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 %% ------------------------------------------------------------------------------------------- %% 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.1.0{\\[-0.5em]\footnotesize(build 11)}}} \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} The Rnw-file: \begin{dispListing} <>= 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}} \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} 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. } \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} <>= 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} \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}} \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}