summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/runcode
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/runcode')
-rw-r--r--macros/latex/contrib/runcode/README2
-rw-r--r--macros/latex/contrib/runcode/runcode.pdfbin251374 -> 251370 bytes
-rw-r--r--macros/latex/contrib/runcode/runcode.sty47
-rw-r--r--macros/latex/contrib/runcode/runcode.tex21
4 files changed, 43 insertions, 27 deletions
diff --git a/macros/latex/contrib/runcode/README b/macros/latex/contrib/runcode/README
index 6075685680..4216dbceea 100644
--- a/macros/latex/contrib/runcode/README
+++ b/macros/latex/contrib/runcode/README
@@ -1,4 +1,4 @@
-LaTeX Package: runcode 2023/09/08 v2.2
+LaTeX Package: runcode 2024/01/12 v2.3
----------------------------------------
The runcode package enables the execution of source code (e.g., R,
Julia, Matlab, shell, Python, etc.) and embed the results in the pdf file
diff --git a/macros/latex/contrib/runcode/runcode.pdf b/macros/latex/contrib/runcode/runcode.pdf
index 0a2d35f5e0..9d91e7e7c9 100644
--- a/macros/latex/contrib/runcode/runcode.pdf
+++ b/macros/latex/contrib/runcode/runcode.pdf
Binary files differ
diff --git a/macros/latex/contrib/runcode/runcode.sty b/macros/latex/contrib/runcode/runcode.sty
index 06c3d346e0..0e1f8014d3 100644
--- a/macros/latex/contrib/runcode/runcode.sty
+++ b/macros/latex/contrib/runcode/runcode.sty
@@ -4,7 +4,7 @@
%
% This package is based on an ongoing work by Haim Bar and HaiYing Wang, and comments and questions are welcome!
-\ProvidesPackage{runcode}[2023/09/08 runcode v2.2]
+\ProvidesPackage{runcode}[2024/01/12 runcode v2.3]
\def \langs {}
@@ -424,10 +424,9 @@
\newcommand{\runcmd}[2]
{python3 -c 'from talk2stat.talk2stat import client; client("./","#1",#2)'}
-% R
-% It will be used as a template for other languages
-\newcommand{\LANG}{R}
-\newcommand{\LANGcmd}{R}
+% a generic LANG - it will be used as a template for other languages
+\newcommand{\LANG}{LANG}
+\newcommand{\LANGcmd}{LANGcmd}
\expandafter\NewDocumentCommand\csname run\LANG\endcsname
{O{} m m O{}}
@@ -451,6 +450,7 @@
{\inln{\runcmd{\LANGcmd}{"\tmpname.txt"}}{#2}[#3][#4]}
}
{\inln{#1}{#2}[#3][#4]}
+ \unskip\unskip\unskip
}
\expandafter\NewDocumentCommand\csname run\LANG Chunk\endcsname
@@ -459,46 +459,59 @@
{\csname run\LANG IncOut\endcsname[#1]{\generated/#2-#3.txt}[#4][#2-#3][#6]}
}
+% R
+\NewDocumentCommand{\runR}{O{} m m O{}}
+{{\renewcommand{\LANGcmd}{R}\runLANG[#1]{#2}{#3}[#4]}}
+
+\NewDocumentCommand{\runRIncOut}{O{} m O{} O{} O{vbox}}
+{{\renewcommand{\LANGcmd}{R}\runLANGIncOut[#1]{#2}[#3][#4][#5]}}
+
+\NewDocumentCommand{\inlnR}{O{} m O{} O{inline}}
+{{\renewcommand{\LANGcmd}{R}\inlnLANG[#1]{#2}[#3][#4]}}
+
+\NewDocumentCommand{\runRChunk}{O{} m m O{} O{} O{vbox}}
+{{\renewcommand{\LANGcmd}{R}\runLANGChunk[#1]{#2}{#3}[#4][#5][#6]}}
+
% Julia
\NewDocumentCommand{\runJulia}{O{} m m O{}}
-{\renewcommand{\LANGcmd}{julia} \runR[#1]{#2}{#3}[#4]}
+{{\renewcommand{\LANGcmd}{julia}\runLANG[#1]{#2}{#3}[#4]}}
\NewDocumentCommand{\runJuliaIncOut}{O{} m O{} O{} O{vbox}}
-{\renewcommand{\LANGcmd}{julia} \runRIncOut[#1]{#2}[#3][#4][#5]}
+{{\renewcommand{\LANGcmd}{julia}\runLANGIncOut[#1]{#2}[#3][#4][#5]}}
\NewDocumentCommand{\inlnJulia}{O{} m O{} O{inline}}
-{\renewcommand{\LANGcmd}{julia} \inlnR[#1]{#2}[#3][#4]}
+{{\renewcommand{\LANGcmd}{julia}\inlnLANG[#1]{#2}[#3][#4]}}
\NewDocumentCommand{\runJuliaChunk}{O{} m m O{} O{} O{vbox}}
-{\renewcommand{\LANGcmd}{julia} \runRChunk[#1]{#2}{#3}[#4][#5][#6]}
+{{\renewcommand{\LANGcmd}{julia}\runLANGChunk[#1]{#2}{#3}[#4][#5][#6]}}
% Matlab
\NewDocumentCommand{\runMatLab}{O{} m m O{}}
-{\renewcommand{\LANGcmd}{matlab} \runR[#1]{#2}{#3}[#4]}
+{{\renewcommand{\LANGcmd}{matlab}\runLANG[#1]{#2}{#3}[#4]}}
\NewDocumentCommand{\runMatLabIncOut}{O{} m O{} O{} O{vbox}}
-{\renewcommand{\LANGcmd}{matlab} \runRIncOut[#1]{#2}[#3][#4][#5]}
+{{\renewcommand{\LANGcmd}{matlab}\runLANGIncOut[#1]{#2}[#3][#4][#5]}}
\NewDocumentCommand{\inlnMatLab}{O{} m O{} O{inline}}
-{\renewcommand{\LANGcmd}{matlab} \inlnR[#1]{#2}[#3][#4]}
+{{\renewcommand{\LANGcmd}{matlab}\inlnLANG[#1]{#2}[#3][#4]}}
\NewDocumentCommand{\runMatLabChunk}{O{} m m O{} O{} O{vbox}}
-{\renewcommand{\LANGcmd}{matlab} \runRChunk[#1]{#2}{#3}[#4][#5][#6]}
+{{\renewcommand{\LANGcmd}{matlab}\runLANGChunk[#1]{#2}{#3}[#4][#5][#6]}}
% Python
\NewDocumentCommand{\runPython}{O{} m m O{}}
-{\renewcommand{\LANGcmd}{python} \runR[#1]{#2}{#3}[#4]}
+{{\renewcommand{\LANGcmd}{python}\runLANG[#1]{#2}{#3}[#4]}}
\NewDocumentCommand{\runPythonIncOut}{O{} m O{} O{} O{vbox}}
-{\renewcommand{\LANGcmd}{python} \runRIncOut[#1]{#2}[#3][#4][#5]}
+{{\renewcommand{\LANGcmd}{python}\runLANGIncOut[#1]{#2}[#3][#4][#5]}}
\NewDocumentCommand{\inlnPython}{O{} m O{} O{inline}}
-{\renewcommand{\LANGcmd}{python} \inlnR[#1]{#2}[#3][#4]}
+{{\renewcommand{\LANGcmd}{python}\inlnLANG[#1]{#2}[#3][#4]}}
\NewDocumentCommand{\runPythonChunk}{O{} m m O{} O{} O{vbox}}
-{\renewcommand{\LANGcmd}{python} \runRChunk[#1]{#2}{#3}[#4][#5][#6]}
+{{\renewcommand{\LANGcmd}{python}\runLANGChunk[#1]{#2}{#3}[#4][#5][#6]}}
%%%%%%%%
diff --git a/macros/latex/contrib/runcode/runcode.tex b/macros/latex/contrib/runcode/runcode.tex
index 23f833bdf5..fb1fd2530e 100644
--- a/macros/latex/contrib/runcode/runcode.tex
+++ b/macros/latex/contrib/runcode/runcode.tex
@@ -1,4 +1,4 @@
-% LaTeX Package: runcode 2023/09/08 v2.2
+% LaTeX Package: runcode 2024/01/12 v2.3
%
% Copyright (C) 2020-2023 by Haim Bar and HaiYing Wang
%
@@ -49,7 +49,7 @@ package’s github repository, at \url{https://github.com/Ossifragus/runcode}.
\end{abstract}
\section{Installation}
-\label{sec:org6031edc}
+\label{sec:orgbc0a4bf}
You can simply put the runcode.sty file in the \LaTeX{} project folder.
The server mode requires the
@@ -65,9 +65,9 @@ compiling a \LaTeX{} document.
\section{Usage}
-\label{sec:org46d9194}
+\label{sec:org6167b11}
\subsection{Load the package:}
-\label{sec:orgdf4d2a5}
+\label{sec:orgc46beda}
\begin{minted}[]{latex}
\usepackage[options]{runcode}
\end{minted}
@@ -139,7 +139,7 @@ be customized with \texttt{\textbackslash{}tcbset},
\end{minted}
\subsection{Basic commands:}
-\label{sec:org1eb4192}
+\label{sec:org9029154}
\begin{itemize}
\item \texttt{\textbackslash{}runExtCode\{Arg1\}\{Arg2\}\{Arg3\}[Arg4]} runs an external code.
@@ -223,7 +223,7 @@ default \texttt{label==} and \texttt{===end}.
\subsection{Extended commands:}
-\label{sec:org2e715a7}
+\label{sec:orgf48d3c2}
\begin{itemize}
\item \texttt{\textbackslash{}runCodeIncOut\{Arg1\}\{Arg2\}[Arg3][Arg4][Arg5]} runs an external code and
embeds the output. This is a combination of \texttt{\textbackslash{}runExtCode} and \texttt{\textbackslash{}includeOutput}.
@@ -240,7 +240,7 @@ functionality is the same as that of \texttt{Arg3} of \texttt{\textbackslash{}in
\end{itemize}
\subsection{Language specific shortcuts:}
-\label{sec:org04ff6f1}
+\label{sec:org506ce7a}
Replace \texttt{LANG} with \texttt{Julia}, \texttt{MatLab}, \texttt{Python}, or \texttt{R}, for the \href{https://julialang.org/}{Julia}, \href{https://www.mathworks.com/products/matlab.html}{MatLab}, \href{https://www.python.org/}{Python}, \href{https://www.r-project.org/}{R}
language, respectively, for the following commands.
@@ -305,8 +305,11 @@ installed via \texttt{pip3 install dill}.
\section{Revisions}
-\label{sec:orgae938b1}
+\label{sec:orgb2671cf}
\begin{itemize}
+\item v2.3, January 12, 2024: two bug fixes (1. removed an extra space after
+\texttt{\textbackslash{}inlnX}; 2. when an underscore appeared inside R code, the tex file would
+compile with an error).
\item v2.2, September 8, 2023: add \texttt{\textbackslash{}showChunk} basic command and \texttt{\textbackslash{}runLANGChunk}
commands for multiple languages.
\item v2.1, June 30, 2023: detokenize code which is passed to \texttt{\textbackslash{}inln}. This is
@@ -341,7 +344,7 @@ code files, zero bytes in output files.)
\end{itemize}
\section{Contributing}
-\label{sec:org9eb0902}
+\label{sec:org3c84ea7}
We welcome your contributions to this package by opening issues on
GitHub and/or making a pull request. We also appreciate more example
documents written using \texttt{runcode}.