diff --git a/.ctan.sh b/.ctan.sh
new file mode 100755
index 0000000..21c0821
--- /dev/null
+++ b/.ctan.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+mkdir runcode
+
+cp -r runcode.sty runcode.tex runcode.pdf runcode_troubleshoot.tex runcode_troubleshoot.pdf README generated runcode/
+
+tar cpvfhz runcode.tar.gz runcode/
+
+rm -r runcode
+
+# tar cpvfhz runcode.tar.gz runcode.sty runcode.tex runcode.pdf troubleshoot.tex troubleshoot.pdf generated ./CTAN/README --transform='flags=r;s|./CTAN/README|README|'
+
+
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..10d754a
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,7 @@
+.gitattributes export-ignore
+.github export-ignore
+.gitignore export-ignore
+LICENSE export-ignore
+FAQ.md export-ignore
+paper export-ignore
+examples export-ignore
\ No newline at end of file
diff --git a/.github/workflows/ctan.yml b/.github/workflows/ctan.yml
new file mode 100644
index 0000000..953f4ba
--- /dev/null
+++ b/.github/workflows/ctan.yml
@@ -0,0 +1,35 @@
+name: Release for CTAN
+
+on:
+ push:
+ tags:
+ - "v*.*"
+jobs:
+ create_tarball:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@master
+ with:
+ fetch-depth: 1
+ - name: seupEmacs
+ uses: purcell/setup-emacs@master
+ with:
+ version: 28.1
+
+ - name: generate runcode.tex
+ run: ./.org2tex.sh
+
+ - name: Compile LaTeX document
+ uses: xu-cheng/latex-action@v2
+ with:
+ root_file: runcode.tex
+ latexmk_shell_escape: true
+
+ - name: create CTAN tarball
+ run: ./.ctan.sh
+
+ - name: Release
+ uses: softprops/action-gh-release@v1
+ with:
+ files: |
+ runcode.tar.gz
diff --git a/.gitignore b/.gitignore
index 8060280..39c3595 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,6 +15,7 @@
*.out
*.synctex.gz
*.mw
+*generated
*tmp
Rplots.pdf
@@ -22,8 +23,6 @@ __pycache__
*.pyc
*debug.txt
-.gitignore
-
*R.config
*Rdebug.txt
*julia.config
@@ -31,5 +30,18 @@ __pycache__
*matlab.config
*matlabdebug.txt
serverPID*.txt
+serverslist.txt
+_minted-runcode/
FAQ.html
+README
+header.tex
+runcode.tar.gz
+runcode.tex
+runcode.hd
+runcode.pdf
+runcode.tex~
+runcode/
+
+# Exceptions
+!examples/Collaborate/generated
diff --git a/.org2tex.el b/.org2tex.el
new file mode 100644
index 0000000..f7f70d5
--- /dev/null
+++ b/.org2tex.el
@@ -0,0 +1,69 @@
+(require 'package)
+(package-initialize)
+(unless package-archive-contents
+ (add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
+ (add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/") t)
+ (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
+ (package-refresh-contents))
+(dolist (pkg '(org))
+ (unless (package-installed-p pkg)
+ (package-install pkg)))
+
+(require 'org)
+;; (require 'oc-csl)
+(require 'ox-publish)
+;; (require 'projectile)
+
+(require 'ox-latex)
+(add-to-list 'org-latex-classes
+ '("ltxdoc"
+ "\\documentclass{ltxdoc}"
+ ("\\section{%s}" . "\\section*{%s}")
+ ("\\subsection{%s}" . "\\subsection*{%s}")
+ ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
+ ("\\paragraph{%s}" . "\\paragraph*{%s}")
+ ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
+
+(setq
+ org-latex-hyperref-template ""
+ ;; org-confirm-babel-evaluate nil
+ org-hide-emphasis-markers t
+ org-latex-listings 'minted
+ org-latex-packages-alist '(("" "minted"))
+ )
+
+;; (defun publish-html-and-patch (plist filename pub-dir)
+;; "Export a html file then patch it by reversing lines"
+;; (let ((outfile (org-html-publish-to-html plist filename pub-dir)))
+;; (shell-command
+;; (format "sed -i 's/Wang, H\\./Wang, H.<\\/strong>/' %s"
+;; outfile (file-name-sans-extension outfile)))))
+
+;; (defvar OS--publish-project-alist
+;; (list
+;; (list "myweb"
+;; :base-directory "./"
+;; :exclude (regexp-opt '("others" "style/others"))
+;; :base-extension "org"
+;; :recursive t
+;; :publishing-directory "./public"
+;; ;; :publishing-function 'org-html-publish-to-html
+;; :publishing-function 'publish-html-and-patch)
+;; (list "attachments"
+;; :base-directory "./"
+;; :exclude (regexp-opt '("public" "others" "style/others"))
+;; ;; :include '("CNAME" "keybase.txt" "LICENSE" ".nojekyll" "publish.el")
+;; :recursive t
+;; :base-extension (regexp-opt '("jpg" "gif" "png" "svg" "css" "pdf" "html"))
+;; :publishing-directory "./public"
+;; :publishing-function 'org-publish-attachment)
+;; ))
+
+;; (defun OS-publish-all ()
+;; (interactive)
+;; (let ((make-backup-files nil)
+;; (org-publish-project-alist OS--publish-project-alist)
+;; (org-html-htmlize-output-type 'css)
+;; (org-cite-csl-styles-dir (expand-file-name "style/" (projectile-project-root))))
+;; (org-publish-all)
+;; ))
diff --git a/.org2tex.sh b/.org2tex.sh
new file mode 100755
index 0000000..1b8d935
--- /dev/null
+++ b/.org2tex.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+emacs README.org --batch --no-init-file --load .org2tex.el -f org-latex-export-to-latex --kill -f toggle-debug-on-error
+
+rl=`sed -n '7p' runcode.sty`
+rl=`echo $rl | sed 's/.*\[\(.*\)\]/\1/'`
+rl=`echo $rl | sed 's/runcode //'`
+VersionDate=$(echo $rl | sed 's/\//\\\//g')
+
+sed "s/XXX-Date Version-XXX/$VersionDate/" CTAN/README > README
+sed "s/XXX-Date Version-XXX/$VersionDate/" CTAN/header.tex > header.tex
+sed -i 's/% Intended LaTeX compiler: pdflatex//' runcode.tex
+
+addheader=`cat header.tex ; cat runcode.tex`
+echo "$addheader" > runcode.tex
+
+
+# sed -i '1d' ./CTAN/README
+# sed '1,1 s/.*/$VersionDate/' ./CTAN/README
+# sed -re "s/XXX-Date Version-XXX/$(VersionDate)/" CTAN/README
+
+# # pdflatex -shell-escape runcode.tex
diff --git a/CTAN/runcode/README b/CTAN/README
similarity index 70%
rename from CTAN/runcode/README
rename to CTAN/README
index 8df8d23..8e55e06 100644
--- a/CTAN/runcode/README
+++ b/CTAN/README
@@ -1,18 +1,21 @@
-LaTeX Package: runcode 2022/07/13 v1.4
+LaTeX Package: runcode XXX-Date Version-XXX
----------------------------------------
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
when compiling the LaTeX file. To use this package the shell-escape
option must be enabled.
-Copyright (C) 2020-2022
+Copyright (C) 2020-2025
Haim Bar and HaiYing Wang https://github.com/Ossifragus/runcode
Files:
- * README - this file
- * runcode.sty - package source
- * runcode.tex - documentation (source)
- * runcode.pdf - documentation (pdf format)
+ * README - this file
+ * runcode.sty - package source
+ * runcode.tex - documentation (source)
+ * runcode.pdf - documentation (pdf format)
+ * runcode_troubleshoot.tex - documentation (source)
+ * runcode_troubleshoot.pdf - documentation (pdf format)
+ * generated/ - a folder which contains files generated by runcode for the runcode_troubleshoot file
Installation:
[manual installation]
diff --git a/CTAN/header.tex b/CTAN/header.tex
new file mode 100644
index 0000000..935273e
--- /dev/null
+++ b/CTAN/header.tex
@@ -0,0 +1,13 @@
+% LaTeX Package: runcode XXX-Date Version-XXX
+%
+% Copyright (C) 2020-2025 by Haim Bar and HaiYing Wang
+%
+% This file 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 2005/12/01 or later.
diff --git a/CTAN/runcode/runcode.pdf b/CTAN/runcode/runcode.pdf
deleted file mode 100644
index a13ff9b..0000000
Binary files a/CTAN/runcode/runcode.pdf and /dev/null differ
diff --git a/CTAN/runcode/runcode.sty b/CTAN/runcode/runcode.sty
deleted file mode 120000
index 20e1f25..0000000
--- a/CTAN/runcode/runcode.sty
+++ /dev/null
@@ -1 +0,0 @@
-../../runcode.sty
\ No newline at end of file
diff --git a/CTAN/runcode/runcode.tex b/CTAN/runcode/runcode.tex
deleted file mode 100644
index cb9edfe..0000000
--- a/CTAN/runcode/runcode.tex
+++ /dev/null
@@ -1,179 +0,0 @@
- % LaTeX Package: runcode v1.1 2021/04/17
- %
- % Copyright (C) 2021 by Haim Bar and HaiYing Wang
- %
- % This file 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 2005/12/01 or later.
-
-\documentclass{ltxdoc}
-\usepackage[hyphens]{url}
-%\usepackage{runcode}
-\ProvidesPackage{runcode}[2022/07/18 runcode v1.4]
-\begin{document}
- \title{The \textsf{runcode} package\thanks{This document corresponds to \textsf{runcode}~v1.4, dated~2022/07/18.}}
- \author{Haim Bar and HaiYing Wang \\ \texttt{haim.bar@uconn.edu}, \texttt{haiying.wang@uconn.edu}}
- \maketitle
-
-\abstract{\textsf{runcode} is a \LaTeX package that executes programming source codes (including all command line tools) from \LaTeX, and embeds the results in the resulting pdf file. Many programming languages can be easily used and any command-line executable can be invoked when preparing the pdf file from a tex file.
-
-It is recommended to use this package in the server-mode together with the Python talk2stat package. Currently, the server-mode supports Julia, MatLab, Python, and R. More languages will be added.
-
-For more details and usage examples and troubleshooting, refer to the package's github repository, at
-\url{https://github.com/Ossifragus/runcode}.
-}
-
-\section{Installation}
-The package on CTAN can be installed automatically by your \TeX\space software (e.g., MikTeX Update Wizard). You can also simply put the runcode.sty file in the \LaTeX\space project folder. To use the package you have to enable the `shell-escape' option when compiling a \LaTeX\space document.
-
-The server mode requires the \textit{talk2stat} Python package. To install it from the command line, use:
-\verb|pip3 install talk2stat|\\
-The \textit{talk2stat} source is available from \url{https://pypi.org/project/talk2stat/}.
-Note that Python version 3.8.* and up is required.
-
-\section{Usage}
-\subsection{Load the package}
-\verb|\usepackage[options]{runcode}|\\
-\\
-Available options are:
-\begin{itemize}
-\item \texttt{julia}: start a \textit{talk2stat} server* for Julia [\url{https://julialang.org/}].
-\item \texttt{matlab}: start a \textit{talk2stat} server* for MatLab [\url{https://www.mathworks.com/products/matlab.html}].
-\item \texttt{R}: start a \textit{talk2stat} server* for R [\url{https://www.r-project.org/}].
-\item \texttt{run}: run source code, and store results in cache files.
-\item \texttt{cache}: use cached results.
-\item \texttt{stopserver}: stop the \textit{talk2stat} server(s) when the pdf compilation is done.
-\item \texttt{nohup}: when using the server-mode, some editors terminate all child processes after LaTeX compiling such as Emacs with Auctex. For this case, use the nohup option. It set the variable notnohup to be false, and the server will not be terminated by the parent process.
-\item \texttt{nominted}: use the \textit{fvextra} package [\url{https://ctan.org/pkg/fvextra}] instead of the \textit{minted} package [\url{https://ctan.org/pkg/minted}] to show code (\textit{fvextra} does not require Python's pygments package [\url{https://pygments.org/}], but it does not provide syntax highlights).
-\end{itemize}
-* Requires the Python package \textit{talk2stat} to be installed.
-
-\subsection{Basic commands}
-\verb|\runExtCode{Arg1}{Arg2}{Arg3}[Arg4]| runs an external code. The arguments are:
-\begin{itemize}
-\item \texttt{Arg1} is the executable program.
-\item \texttt{Arg2} is the source file name.
-\item \texttt{Arg3} is the output file name (with an empty value, the counter `codeOutput` is used).
-\item \texttt{Arg4} controls whether to run the code. \texttt{Arg4} is optional with three possible values: if skipped or with empty value, the value of the global Boolean variable \texttt{runcode} as determined by the \texttt{run} option when loading the package, is used; if the value is set to `run`, the code will be executed; if set to `cache` (or anything else), use cached results (see more about the cache below).
-\end{itemize}
-
-\bigskip
-\noindent \verb|\showCode{Arg1}{Arg2}[Arg3][Arg4]| shows the source code, using minted for a pretty layout or fvextra (if pygments is not installed).
-\begin{itemize}
-\item \texttt{Arg1} is the programming language.
-\item \texttt{Arg2} is the source file name.
-\item \texttt{Arg3} is the first line to show (optional with a default value 1).
-\item \texttt{Arg4} is the last line to show (optional with a default value of the last line).
-\end{itemize}
-
-\bigskip
-\noindent \verb|\includeOutput{Arg1}[Arg2]| is used to embed the output from executed code.
-\begin{itemize}
-\item \texttt{Arg1} is the output file name, and it needs to have the same value as that of \texttt{Arg3} in \verb|\runExtCode|. If an empty value is given to \texttt{Arg1}, the counter `codeOutput` is used.
-\item \texttt{Arg2} is optional and it controls the type of output with a default value `vbox`
-\begin{itemize}
-\item \texttt{vbox} (or skipped) = verbatim in a box.
-\item \texttt{tex} = pure latex.
-\item \texttt{inline} = embed result in text.
-\end{itemize}
-\end{itemize}
-
-\bigskip
-\noindent \verb|\inln{Arg1}{Arg2}[Arg3]| is designed for simple calculations; it runs one command (or a short batch) and displays the output within the text.
-\begin{itemize}
-\item \texttt{Arg1} is the executable program or programming language.
-\item \texttt{Arg2} is the source code.
-\item \texttt{Arg3} is the output type.
-\begin{itemize}
-\item \texttt{inline} (or skipped or with empty value) = embed result in text.
-\item \texttt{vbox} = verbatim in a box.
-\end{itemize}
-\end{itemize}
-
-\subsection{Language specific shortcuts}
-\verb|\runJulia[Arg1]{Arg2}{Arg3}[Arg4]| runs an external Julia code file.
-\begin{itemize}
-\item \texttt{Arg1} is optional and uses \textit{talk2stat}'s Julia server by default.
-\item \texttt{Arg2}, \texttt{Arg3}, and \texttt{Arg4} have the same effects as those of the basic command \verb|\runExtCode|.
-\end{itemize}
-
-\noindent \verb|\inlnJulia[Arg1]{Arg2}[Arg3]| runs Julia source code (\texttt{Arg2}) and displays the output in line.
-\begin{itemize}
-\item \texttt{Arg1} is optional and uses the Julia server by default.
-\item \texttt{Arg2} is the Julia source code to run. If the Julia source code is wrapped between \verb|```| on both sides (as in the markdown grammar), then it will be implemented directly; otherwise the code will be written to a file on the disk and then be called.
-\item \texttt{Arg3} has the same effect as that of the basic command \verb|\inln|.
-\end{itemize}
-
-\bigskip
-\noindent \verb|\runMatLab[Arg1]{Arg2}{Arg3}[Arg4]| runs an external MatLab code file.
-\begin{itemize}
-\item \texttt{Arg1} is optional and uses \textit{talk2stat}'s MatLab server by default.
-\item \texttt{Arg2}, \texttt{Arg3}, and \texttt{Arg4} have the same effects as those of the basic command \verb|\runExtCode|.
-\end{itemize}
-
-\noindent
-\verb|\inlnMatLab[Arg1]{Arg2}[Arg3]| runs MatLab source code (\texttt{Arg2}) and displays the output in line.
-\begin{itemize}
-\item \texttt{Arg1} is optional and uses the MatLab server by default.
-\item \texttt{Arg2} is the MatLab source code to run. If the MatLab source code is wrapped between \verb|```| on both sides (as in the markdown grammar), then it will be implemented directly; otherwise the code will be written to a file on the disk and then be called.
-\item \texttt{Arg3} has the same effect as that of the basic command \verb|\inln|.
-\end{itemize}
-
-
-\bigskip
-\noindent \verb|\runR[Arg1]{Arg2}{Arg3}[Arg4]| runs an external R code file.
-\begin{itemize}
-\item \texttt{Arg1} is optional and uses \textit{talk2stat]}'s R server by default.
-\item \texttt{Arg2}, \texttt{Arg3}, and \texttt{Arg4} have the same effects as those of the basic command \verb|\runExtCode|.
-\end{itemize}
-
-\noindent \verb|\inlnR[Arg1]{Arg2}[Arg3]| runs R source code (\texttt{Arg2}) and displays the output in line.
-\begin{itemize}
-\item \texttt{Arg1} is optional and uses the R server by default.
-\item \texttt{Arg2} is the R source code to run. If the R source code is wrapped between \verb|```| on both sides (as in the markdown grammar), then it will be implemented directly; otherwise the code will be written to a file on the disk and then be called.
-\item \texttt{Arg3} has the same effect as that of the basic command \verb|\inln|.
-\end{itemize}
-
-
-\bigskip
-\noindent \verb|\runPython[Arg1]{Arg2}{Arg3}[Arg4]| runs an external Python code file.
-\begin{itemize}
-\item \texttt{Arg1} is optional and uses \textit{talk2stat]}'s Python server by default.
-\item \texttt{Arg2}, \texttt{Arg3}, and \texttt{Arg4} have the same effects as those of the basic command \verb|\runExtCode|.
-\end{itemize}
-
-\noindent \verb|\inlnPython[Arg1]{Arg2}[Arg3]| runs Python source code (\texttt{Arg2}) and displays the output in line.
-\begin{itemize}
-\item \texttt{Arg1} is optional and uses the Python server by default.
-\item \texttt{Arg2} is the R source code to run. If the Python source code is wrapped between \verb|```| on both sides (as in the markdown grammar), then it will be implemented directly; otherwise the code will be written to a file on the disk and then be called.
-\item \texttt{Arg3} has the same effect as that of the basic command \verb|\inln|.
-\end{itemize}
-
-\noindent \verb|\runPythonBatch[Arg1][Arg2]| runs an external Python source code (\texttt{Arg1}) in batch mode (without a server running). Python (at least currently), unlike the other languages we use, does not have an option to save and restore a session, which means that once a Python session ends, the working environment (variable, functions) is deleted. In order to allow a batch-mode in Python, we implemented such capability. It requires the dill module (https://pypi.org/project/dill/) module, which has to be installed via `pip3 install dill`.
-\begin{itemize}
-\item \texttt{Arg1} is the Python source code to run.
-\item \texttt{Arg2} is the output file name.
-\end{itemize}
-
-
-
-
-\section{Revisions}
-\begin{itemize}
-\item v1.4, July 18, 2022: Fixed a bug in the cache mode.
-\item v1.3, May 14, 2022: Removed the hard-coded minted options.
-\item v1.2, May 3, 2022: Added python options (server and batch).
-\item v1.1, April 17, 2021: Added a nohup option; improved error handling (missing code files, zero bytes in output files.)
-\end{itemize}
-
-%
-\section{Contributing}
-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 \textsf{runcode}.
-
-\end{document}
diff --git a/README.md b/README.md
deleted file mode 100644
index 1514a4d..0000000
--- a/README.md
+++ /dev/null
@@ -1,242 +0,0 @@
-# runcode
-
-`runcode` is a LaTeX package that executes programming source codes (including
-all command line tools) from LaTeX, and embeds the results in the resulting pdf
-file. Many programming languages can be easily used and any command-line
-executable can be invoked when preparing the pdf file from a tex file. `runcode`
-is also available on [CTAN](https://ctan.org/pkg/runcode).
-
-It is recommended to use this package in the server mode together with the
-[Python](https://www.python.org/)
-[talk2stat](https://pypi.org/project/talk2stat/) package. Currently, the server
-mode supports [Julia](https://julialang.org/),
-[MatLab](https://www.mathworks.com/products/matlab.html),
-[Python](https://www.python.org/), and [R](https://www.r-project.org/). More
-languages will be added.
-
-**Citing `runcode`:** *Haim Bar and HaiYing Wang (2021). Reproducible Science
-with LaTeX, [https://jds-online.org/journal/JDS/article/103/info] J. data
-sci. 2021; 19, no. 1, 111-125, DOI 10.6339/21-JDS998*
-
-## Installation
-
-You can simply put the runcode.sty file in the LaTeX project folder.
-
-The server mode requires the [talk2stat](https://pypi.org/project/talk2stat/)
-package. To install it from the command line, use:
-
-```
-pip3 install talk2stat
-```
-
-**Note**: `runcode` requires to enable the `shell-escape` option when compiling
-a LaTeX document.
-
-
-
-
-
-
-
-
-## Usage
-
-### Load the package:
-
-```latex
-\usepackage[options]{runcode}
-```
-
-Available options are:
-
-- `cache`: use cached results.
-
-- `julia`: start server for [Julia](https://julialang.org/) (requires
- [talk2stat](https://pypi.org/project/talk2stat/)).
-
-- `matlab`: start server for
- [MatLab](https://www.mathworks.com/products/matlab.html) (requires
- [talk2stat](https://pypi.org/project/talk2stat/)).
-
-- `nominted`: use the [fvextra](https://ctan.org/pkg/fvextra) package instead of
- the [minted](https://ctan.org/pkg/minted) package to show code (this does not
- require the [pygments](https://pygments.org/) package, but it does not provide
- syntax highlights).
-
-- `nohup`: use the `nohup` command when starting a server. When using the
- server-mode, some editors terminate all child processes after LaTeX compiling
- such as Emacs with Auctex. This option set the variable notnohup to be false,
- and the server will not be terminated by the parent process. **This option
- has to be declared before declaring any language**, e.g., `[nohup, R]` works
- but `[R, nohup]` does not work.
-
-- `python`: start server for [Python](https://www.python.org/) (requires
- [talk2stat](https://pypi.org/project/talk2stat/)).
-
-- `run`: run source code.
-
-- `R`: start server for [R](https://www.r-project.org/) (requires
- [talk2stat](https://pypi.org/project/talk2stat/)).
-
-- `stopserver`: stop the server(s) when the pdf compilation is done.
-
-**Note**: If [minted](https://ctan.org/pkg/minted) is used, the style of the code block is controlled through the minted package, [e.g.:](https://github.com/Ossifragus/runcode/blob/master/examples/MontyHall/MontyHall.tex#L3-L4)
-```latex
-\setminted[julia]{linenos, frame=single, bgcolor=bg, breaklines=true}
-\setminted[R]{linenos, frame=single, bgcolor=lightgray, breaklines=true}
-```
-The outputs from executing codes are displayed in [tcolorbox](https://ctan.org/pkg/tcolorbox?lang=en), so the style can be customized with `\tcbset`, [e.g.:](https://github.com/Ossifragus/runcode/blob/master/examples/MontyHall/MontyHall.tex#L5)
-```latex
-\tcbset{breakable,colback=red!5!white,colframe=red!75!black}
-```
-
-### Basic commands:
-
-- `\runExtCode{Arg1}{Arg2}{Arg3}[Arg4]` runs an external code.
-
- - `Arg1` is the executable program.
- - `Arg2` is the source file name.
- - `Arg3` is the output file name (with an empty value, the counter
- `codeOutput` is used).
- - `Arg4` controls whether to run the code. `Arg4` is optional with three
- possible values: if skipped or with empty value, the value of the global
- Boolean variable `runcode` is used; if the value is set to `run`, the code
- will be executed; if set to `cache` (or anything else), use cached results
- (see more about the cache below).
-
-- `\showCode{Arg1}{Arg2}[Arg3][Arg4]` shows the source code, using
- [minted](https://ctan.org/pkg/minted) for a pretty layout or
- [fvextra](https://ctan.org/pkg/fvextra) (if [pygments](https://pygments.org/)
- is not installed).
-
- - `Arg1` is the programming language.
- - `Arg2` is the source file name.
- - `Arg3` is the first line to show (optional with a default value 1).
- - `Arg4` is the last line to show (optional with a default value of the last
- line).
-
-- `\includeOutput{Arg1}[Arg2]` is used to embed the output from executed code.
-
- - `Arg1` is the output file name, and it needs to have the same value as that
- of `Arg3` in `\runExtCode`. If an empty value is given to `Arg1`, the
- counter `codeOutput` is used.
- - `Arg2` is optional and it controls the type of output with a default value
- `vbox`
- - `vbox` (or skipped) = verbatim in a box.
- - `tex` = pure latex.
- - `inline` = embed result in text.
-
-- `\inln{Arg1}{Arg2}[Arg3]` is designed for simple calculations; it runs one
- command (or a short batch) and displays the output within the text.
-
- - `Arg1` is the executable program or programming language.
- - `Arg2` is the source code.
- - `Arg3` is the output type.
- - `inline` (or skipped or with empty value) = embed result in text.
- - `vbox` = verbatim in a box.
-
-### Language specific shortcuts:
-
-[Julia](https://julialang.org/)
-
-- `\runJulia[Arg1]{Arg2}{Arg3}[Arg4]` runs an external
- [Julia](https://julialang.org/) code file.
- - `Arg1` is optional and uses
- [talk2stat](https://pypi.org/project/talk2stat/)'s
- [Julia](https://julialang.org/) server by default.
- - `Arg2`, `Arg3`, and `Arg4` have the same effects as those of the basic
- command `\runExtCode`.
-- `\inlnJulia[Arg1]{Arg2}[Arg3]` runs [Julia](https://julialang.org/) source
- code (`Arg2`) and displays the output in line.
- - `Arg1` is optional and uses the [Julia](https://julialang.org/) server by
- default.
- - `Arg2` is the [Julia](https://julialang.org/) source code to run. If the
- [Julia](https://julialang.org/) source code is wrapped between "```" on both
- sides (as in the markdown grammar), then it will be implemented directly;
- otherwise the code will be written to a file on the disk and then be called.
- - `Arg3` has the same effect as that of the basic command `\inln`.
-
-[MatLab](https://www.mathworks.com/products/matlab.html)
-
-- `\runMatLab[Arg1]{Arg2}{Arg3}[Arg4]` runs an external
- [MatLab](https://www.mathworks.com/products/matlab.html) code file.
- - `Arg1` is optional and uses
- [talk2stat](https://pypi.org/project/talk2stat/)'s
- [MatLab](https://www.mathworks.com/products/matlab.html) server by default.
- - `Arg2`, `Arg3`, and `Arg4` have the same effects as those of the basic
- command `\runExtCode`.
-- `\inlnMatLab[Arg1]{Arg2}[Arg3]` runs
- [MatLab](https://www.mathworks.com/products/matlab.html) source code (`Arg2`)
- and displays the output in line.
- - `Arg1` is optional and uses the
- [MatLab](https://www.mathworks.com/products/matlab.html) server by default.
- - `Arg2` is the [MatLab](https://www.mathworks.com/products/matlab.html)
- source code to run. If the
- [MatLab](https://www.mathworks.com/products/matlab.html) source code is
- wrapped between "```" on both sides (as in the markdown grammar), then it
- will be implemented directly; otherwise the code will be written to a file
- on the disk and then be called.
- - `Arg3` has the same effect as that of the basic command `\inln`.
-
-[R](https://www.r-project.org/)
-
-- `\runR[Arg1]{Arg2}{Arg3}[Arg4]` runs an external
- [R](https://www.r-project.org/) code file.
- - `Arg1` is optional and uses
- [talk2stat](https://pypi.org/project/talk2stat/)'s
- [R](https://www.r-project.org/) server by default.
- - `Arg2`, `Arg3`, and `Arg4` have the same effects as those of the basic
- command `\runExtCode`.
-- `\inlnR[Arg1]{Arg2}[Arg3]` runs [R](https://www.r-project.org/) source code
- (`Arg2`) and displays the output in line.
- - `Arg1` is optional and uses the [R](https://www.r-project.org/) server by
- default.
- - `Arg2` is the [R](https://www.r-project.org/) source code to run. If the
- [R](https://www.r-project.org/) source code is wrapped between "```" on both
- sides (as in the markdown grammar), then it will be implemented directly;
- otherwise the code will be written to a file on the disk and then be called.
- - `Arg3` has the same effect as that of the basic command `\inln`.
-
-
-[Python](https://www.python.org/)
-
-- `\runPython[Arg1]{Arg2}{Arg3}[Arg4]` runs an external
- [Python](https://www.python.org/) code file.
- - `Arg1` is optional and uses
- [talk2stat](https://pypi.org/project/talk2stat/)'s
- [Julia](https://julialang.org/) server by default.
- - `Arg2`, `Arg3`, and `Arg4` have the same effects as those of the basic
- command `\runExtCode`.
-- `\inlnPython[Arg1]{Arg2}[Arg3]` runs [Python](https://www.python.org/) source
- code (`Arg2`) and displays the output in line.
- - `Arg1` is optional and uses the [Python](https://www.python.org/) server by
- default.
- - `Arg2` is the [Julia](https://julialang.org/) source code to run. If the
- [Python](https://www.python.org/) source code is wrapped between "```" on both
- sides (as in the markdown grammar), then it will be implemented directly;
- otherwise the code will be written to a file on the disk and then be called.
- - `Arg3` has the same effect as that of the basic command `\inln`.
-
-- `\runPythonBatch[Arg1][Arg2]` runs an external
- [Python](https://www.python.org/) code file in batch mode (without a server running).
- Python (at least currently), unlike the other languages we use, does not have an option
- to save and restore a session, which means that once a Python session ends, the
- working environement (variable, functions) is deleted. In order to allow a batch-mode
- in Python, we implemented such capability. It requires the
- [dill](https://pypi.org/project/dill/) module, which has to be installed via
- `pip3 install dill`.
- - `Arg1` is the [Python](https://www.python.org/) source file name,
- - `Arg2` is the output file name.
-
-
-
-
-
-
-
-
-## Contributing
-
-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
-`runcode`.
diff --git a/README.org b/README.org
new file mode 100644
index 0000000..a38ef6a
--- /dev/null
+++ b/README.org
@@ -0,0 +1,316 @@
+# -*- org-latex-hyperref-template: ""; org-latex-prefer-user-labels: t -*-
+
+#+startup: content hideblocks
+#+options: H:2 timestamp:nil tex:t toc:nil author:nil
+#+EXPORT_FILE_NAME: runcode.tex
+
+#+LaTeX_CLASS: ltxdoc
+#+latex_header: \author{Haim Bar and HaiYing Wang \\haim.bar@uconn.edu, haiying.wang@uconn.edu}
+
+#+TITLE: The *runcode* package
+
+#+begin_export latex
+\begin{abstract}
+#+end_export
+
+=runcode= is a LaTeX package that executes programming source codes (including
+all command line tools) from LaTeX, and embeds the results in the resulting pdf
+file. Many programming languages can be easily used and any command-line
+executable can be invoked when preparing the pdf file from a tex file. =runcode=
+is also available on [[https://ctan.org/pkg/runcode][CTAN]].
+
+It is recommended to use this package in the server mode together with the
+[[https://www.python.org/][Python]] [[https://pypi.org/project/talk2stat/][talk2stat]] package. Currently, the server mode supports [[https://julialang.org/][Julia]], [[https://www.mathworks.com/products/matlab.html][MatLab]],
+[[https://www.python.org/][Python]], and [[https://www.r-project.org/][R]]. More languages will be added.
+
+#+begin_export latex
+For more details and usage examples and troubleshooting, refer to the
+package’s github repository, at \url{https://github.com/Ossifragus/runcode}.
+
+\end{abstract}
+#+end_export
+
+** Installation
+:PROPERTIES:
+:CUSTOM_ID: installation
+:END:
+You can simply put the runcode.sty file in the LaTeX project folder.
+
+The server mode requires the [[https://pypi.org/project/talk2stat/][talk2stat]] package, and some chunk command (e.g.,
+=\showChunk=) requires the [[https://pypi.org/project/advance-touch/][advance-touch]] package. To install them from the
+command line, use:
+
+#+begin_example
+pip3 install talk2stat advance-touch
+#+end_example
+
+*Note*: =runcode= requires to enable the =shell-escape= option when
+compiling a LaTeX document.
+
+
+** Usage
+:PROPERTIES:
+:CUSTOM_ID: usage
+:END:
+*** Load the package:
+:PROPERTIES:
+:CUSTOM_ID: load-the-package
+:END:
+#+begin_src latex :exports code
+\usepackage[options]{runcode}
+#+end_src
+
+Available options are:
+
+- =cache=: use cached results.
+
+- =fvextra=: use the [[https://ctan.org/pkg/fvextra][fvextra]] package to show code.
+
+- =julia=: start server for [[https://julialang.org/][Julia]] (requires [[https://pypi.org/project/talk2stat/][talk2stat]]).
+
+- =listings=: use the [[https://ctan.org/pkg/listings?lang=en][listings]] package to show code.
+
+- =matlab=: start server for [[https://www.mathworks.com/products/matlab.html][MatLab]] (requires [[https://pypi.org/project/talk2stat/][talk2stat]]).
+
+- =minted=: use the [[https://ctan.org/pkg/minted][minted]] package to show code (requires the [[https://pygments.org/][pygments]] package).
+ This is the default option.
+
+- =nominted=: use the [[https://ctan.org/pkg/fvextra][fvextra]] package
+ instead of the [[https://ctan.org/pkg/minted][minted]] package to show
+ code (this does not require the [[https://pygments.org/][pygments]]
+ package, but it does not provide syntax highlights).
+
+- =nohup=: use the =nohup= command when starting a server. When using
+ the server-mode, some editors terminate all child processes after
+ LaTeX compiling such as Emacs with Auctex. This option set the
+ variable notnohup to be false, and the server will not be terminated
+ by the parent process. *This option has to be declared before
+ declaring any language*, e.g., =[nohup, R]= works but =[R, nohup]=
+ does not work.
+
+- =python=: start server for [[https://www.python.org/][Python]]
+ (requires [[https://pypi.org/project/talk2stat/][talk2stat]]).
+
+- =run=: run source code.
+
+- =R=: start server for [[https://www.r-project.org/][R]] (requires
+ [[https://pypi.org/project/talk2stat/][talk2stat]]).
+
+- =stopserver=: stop the server(s) when the pdf compilation is done.
+
+*Note*: If [[https://ctan.org/pkg/minted][minted]] is used, the style of
+the code block is controlled through the minted package,
+[[https://github.com/Ossifragus/runcode/blob/master/examples/MontyHall/MontyHall.tex#L3-L4][e.g.:]]
+
+#+begin_src latex :exports code
+\setminted[julia]{linenos, frame=single, bgcolor=bg, breaklines=true}
+\setminted[R]{linenos, frame=single, bgcolor=lightgray, breaklines=true}
+#+end_src
+
+Similarly, [[https://ctan.org/pkg/fvextra][fvextra]] and [[https://ctan.org/pkg/listings?lang=en][listings]] packages can be customized through the =\fvset=
+and =\lstset= commands, respectively, e.g.:
+
+#+begin_src latex :exports code
+\fvset{fontsize=\small, linenos=true, frame=single}
+\lstset{basicstyle=\large, frame=single}
+#+end_src
+
+The outputs from executing codes are displayed in
+[[https://ctan.org/pkg/tcolorbox?lang=en][tcolorbox]], so the style can
+be customized with =\tcbset=,
+[[https://github.com/Ossifragus/runcode/blob/master/examples/MontyHall/MontyHall.tex#L5][e.g.:]]
+
+#+begin_src latex :exports code
+\tcbset{breakable,colback=red!5!white,colframe=red!75!black}
+#+end_src
+
+*** Basic commands:
+:PROPERTIES:
+:CUSTOM_ID: basic-commands
+:END:
+- =\runExtCode{Arg1}{Arg2}{Arg3}[Arg4]= runs an external code.
+
+ - =Arg1= is the executable program.
+ - =Arg2= is the source file name.
+ - =Arg3= is the output file name (with an empty value, the counter =codeOutput= is
+ used).
+ - =Arg4= controls whether to run the code. =Arg4= is optional with three possible
+ values.
+ - empty value or skipped: the value of the global Boolean variable =runcode=
+ is used;
+ - =run=: the code will be executed;
+ - =cache= (or anything else): use cached results; if the output file does not
+ exist, the cache option will be overridden and the code will run.
+
+- =\showCode{Arg1}{Arg2}[Arg3][Arg4]= shows the source code, using
+ [[https://ctan.org/pkg/minted][minted]] (requires [[https://pygments.org/][pygments]]), [[https://ctan.org/pkg/fvextra][fvextra]], or [[https://ctan.org/pkg/listings?lang=en][listings]].
+
+ - =Arg1= is the programming language.
+ - =Arg2= is the source file name.
+ - =Arg3= is the first line to show (optional with a default value 1).
+ - =Arg4= is the last line to show (optional with a default value of
+ the last line).
+
+- =\includeOutput{Arg1}[Arg2]= is used to embed the output from executed
+ code.
+
+ - =Arg1= is the output file name, and it needs to have the same value
+ as that of =Arg3= in =\runExtCode=. If an empty value is given to
+ =Arg1=, the counter =codeOutput= is used.
+ - =Arg2= is optional and it controls the type of output with a default
+ value =vbox=.
+ - =vbox= (or skipped) = verbatim in a box;
+ - =tex= = pure latex;
+ - =inline= = embed result in text.
+
+- =\inln{Arg1}{Arg2}[Arg3][Arg4]= is designed for simple calculations; it runs
+ one command (or a short batch) and displays the output within the
+ text.
+
+ - =Arg1= is the executable program or programming language.
+ - =Arg2= is the source code.
+ - =Arg3= is the output file name (optional);
+ - =Arg4= is the output type and controls whether to run the code.
+ - =inline= (or skipped or with empty value): embed result in text;
+ - =vbox=: verbatim in a box;
+ - =cache= or appending =.cache= to the argument (e.g., =vbox.cache=) AND the
+ output file in =Arg3= exists: the cached result will be used and the code
+ will not run.
+
+- =\showChunk{Arg1}{Arg2}[Arg3][Arg4]= prints a selected chunk from source
+ code. The chunk is identified in the source code by two strings that define
+ the beginning and end of the chunk. The default beginning is =label=== The Wisconsin Breast Cancer dataset is available as a comma-delimited text file on the
- UCI Machine Learning Server (http://archive.ics.uci.edu/ml).
+ UCI Machine Learning Server (https://archive.ics.uci.edu/).
The dataset contains 699 fine-needle aspirate samples, where 458 (65.5%) are benign and 241 (34.5%) are
malignant.
The dataset contains a total of 11 variables and doesn’t include the variable names in the file.
@@ -48,7 +48,7 @@ Demonstrating how to use the talk2stat package with NodeJS
for the back-end. The structure and functionality of the form is also entirely up to the user, and developing
elaborate dashboards is possible.
Demonstrating how to use the talk2stat package with NodeJS
In this example we will try different methods for predicting whether a patient has breast cancer from the characteristics of a
fine-needle tissue aspiration (a tissue sample taken with a thin hollow needle from a lump or mass just under the skin).
Choose the type of classifier fromt he four available options, and the percentage of the data to be used for training.
+Choose the type of classifier from the four available options, and the percentage of the data to be used for training.