summaryrefslogtreecommitdiff
path: root/Master/texmf-dist
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2022-08-11 20:45:40 +0000
committerKarl Berry <karl@freefriends.org>2022-08-11 20:45:40 +0000
commit55623bdb3d6ba6af457b741ab9765a844b259fc9 (patch)
treec34f28aabe4fdede72f9a215f42de26c476ca937 /Master/texmf-dist
parent1b5abb7439af0f95d3d341cfc02176216850a04c (diff)
runcode (11aug22)
git-svn-id: svn://tug.org/texlive/trunk@64097 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r--Master/texmf-dist/doc/latex/runcode/README3
-rw-r--r--Master/texmf-dist/doc/latex/runcode/runcode.pdfbin188821 -> 56780 bytes
-rw-r--r--Master/texmf-dist/doc/latex/runcode/runcode.tex10
-rw-r--r--Master/texmf-dist/doc/latex/runcode/troubleshoot.pdfbin0 -> 66837 bytes
-rw-r--r--Master/texmf-dist/doc/latex/runcode/troubleshoot.tex309
-rw-r--r--Master/texmf-dist/tex/latex/runcode/runcode.sty49
6 files changed, 351 insertions, 20 deletions
diff --git a/Master/texmf-dist/doc/latex/runcode/README b/Master/texmf-dist/doc/latex/runcode/README
index 4d3e095094a..99088129e63 100644
--- a/Master/texmf-dist/doc/latex/runcode/README
+++ b/Master/texmf-dist/doc/latex/runcode/README
@@ -1,4 +1,4 @@
-LaTeX Package: runcode 2022/07/23 v1.5
+LaTeX Package: runcode 2022/08/10 v1.6
----------------------------------------
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
@@ -13,6 +13,7 @@ Files:
* runcode.sty - package source
* runcode.tex - documentation (source)
* runcode.pdf - documentation (pdf format)
+ * runcodetroubleshoot.pdf (pdf format)
Installation:
[manual installation]
diff --git a/Master/texmf-dist/doc/latex/runcode/runcode.pdf b/Master/texmf-dist/doc/latex/runcode/runcode.pdf
index 045989d6b5e..803a3a401eb 100644
--- a/Master/texmf-dist/doc/latex/runcode/runcode.pdf
+++ b/Master/texmf-dist/doc/latex/runcode/runcode.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/runcode/runcode.tex b/Master/texmf-dist/doc/latex/runcode/runcode.tex
index 8c2892eb95d..576f47d8cf9 100644
--- a/Master/texmf-dist/doc/latex/runcode/runcode.tex
+++ b/Master/texmf-dist/doc/latex/runcode/runcode.tex
@@ -1,4 +1,4 @@
- % LaTeX Package: runcode v1.5 2022/07/23
+ % LaTeX Package: runcode v1.6 2022/08/10
%
% Copyright (C) 2021 by Haim Bar and HaiYing Wang
%
@@ -14,10 +14,9 @@
\documentclass{ltxdoc}
\usepackage[hyphens]{url}
-%\usepackage{runcode}
-\ProvidesPackage{runcode}[2022/07/23 runcode v1.5]
+\usepackage{runcode}
\begin{document}
- \title{The \textsf{runcode} package\thanks{This document corresponds to \textsf{runcode}~v1.5, dated~2022/07/23.}}
+ \title{The \textsf{runcode} package\thanks{This document corresponds to \textsf{runcode}~v1.6, dated~2022/08/10.}}
\author{Haim Bar and HaiYing Wang \\ \texttt{haim.bar@uconn.edu}, \texttt{haiying.wang@uconn.edu}}
\maketitle
@@ -51,6 +50,7 @@ Available options are:
\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).
+\item \texttt{reducedspace}: with some document classes minted puts too much space after an embedded block of code. Use this option to remove the extra space.
\end{itemize}
* Requires the Python package \textit{talk2stat} to be installed.
@@ -166,6 +166,7 @@ Available options are:
\section{Revisions}
\begin{itemize}
+\item v1.6, August 10, 2022: stop only configured/running servers; a new reducedspace option - some document classes put more space after the code box; changed the default timeout of servers to 60 seconds; expanded the troubleshooting document. New examples are now available on GitHub, including how to collaborate with people who use Overleaf.
\item v1.5, July 23, 2022: Removed the utf8x option when loading inputenc due to a conflict with hyperref.
\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.
@@ -173,6 +174,7 @@ Available options are:
\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}.
diff --git a/Master/texmf-dist/doc/latex/runcode/troubleshoot.pdf b/Master/texmf-dist/doc/latex/runcode/troubleshoot.pdf
new file mode 100644
index 00000000000..c170da9113c
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/runcode/troubleshoot.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/runcode/troubleshoot.tex b/Master/texmf-dist/doc/latex/runcode/troubleshoot.tex
new file mode 100644
index 00000000000..0a37015b9b6
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/runcode/troubleshoot.tex
@@ -0,0 +1,309 @@
+\documentclass[a4paper,10pt]{article}
+\usepackage[a4paper, total={6in, 10in}]{geometry}
+%\usepackage[square,sort,comma]{natbib}
+%\usepackage[R,stopserver]{runcode}
+\usepackage[cache]{runcode}
+
+\usepackage{caption}
+%\usepackage{subcaption}
+\usepackage{subfig}
+
+
+\newcommand{\prob}[1] {\bigskip\noindent\textbf{\textcolor{orange}{Problem:}}\\#1\\\\}
+\newcommand{\cause}[1] {\noindent\textit{\textcolor{blue}{Possible reason and solution:}}\\#1}
+\newcommand{\cmnt}[1] {\bigskip\noindent\textit{Notes:} #1}
+
+% Title Page
+\title{The runcode package -- troubleshooting}
+\author{Haim Bar and HaiYing Wang}
+
+
+\begin{document}
+\maketitle
+
+When using the runcode package, you have to be aware of some usage rules, so this document attempts to anticipate all the possible user or system errors, and show how to interpret the output and fix the problems.
+
+\subsection*{Before you start using runcode}
+
+Before using the package make sure that you have Python (version 3.x) installed and in your path. Also, you must install the required \LaTeX~ packages:
+morewrites, tcolorbox, xcolor, inputenc, textgreek, filecontents, xifthen, xparse, xstring, and fvextra. The minted package is optional but recommended.
+
+If you try to compile this file from its tex source, you will get errors (because the purpose of this document is to demonstrate errors and how to fix them.) It is assumed that you are using a cloned runcode repository, so files used in this document are ones in the directory structure as it is stored on github.
+
+The files generated by runcode live in the project's directory, so we assume the user has the necessary permissions to create, modify, delete files and subfolder.
+
+For the server mode the folder must contain a configuration file for each statistical language used (R, julia, matlab, Python). If such files don't exist, runcode will create them with default values. Remember to check if the defaults work for you. For example, you may need to change the port number, or increase the timeout parameter.
+
+\subsection*{Some possible errors and solutions}
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\prob{runcode functions are not executed.}
+\cause\bgroup
+Check if you enabled the \verb|shell-escape| option when the document is compiled. If not, you will see warnings in the project's log file. For example:
+\begin{Verbatim}
+Package ifplatform Warning:
+ shell escape is disabled, so I can only detect \ifwindows.
+! Package minted Error: You must invoke LaTeX with the -shell-escape flag.
+\end{Verbatim}
+\egroup
+
+\cause\bgroup
+Check if the command-line tools you invoke from runcode are installed, and in your path (e.g., R, Julia, Matlab, Python).
+\egroup
+
+\cmnt\bgroup
+The runcode package can call any command-line function when it is used in `batch-mode'. That is, when the command-line tool is called separately each time a computation is performed from within the tex document (upon compilation). When using R, Julia, Python, or Matlab, the user can maintain a continuous session to the corresponding command-line tool. This saves initialization time, and allows to keep a session's history, for performing steps sequentially and efficiently. This is the recommended way to use runcode with R, Julia, Python, and Matlab.
+At the present time, no other languages are supported for `server-mode' operation.
+\egroup
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\prob{Code highlighting is not working properly.}
+\cause\bgroup
+When code is included in the manuscript, it is done via the \verb|\showCode| command. By default, the code-highlighting it done via the minted package. If code highlighting doesn't work, check if the minted package is installed properly. Python (3.x) also has to be installed, and also the Pygments package (which has to be installed via pip3). If you have trouble with the installation of minted, use the \verb|nominted| option when you include the runcode package. This will cause runcode to use the fvextra for code display, instead.
+\egroup
+
+
+\prob{Embedded code is not shown.}
+\cause\bgroup
+Check if you specified the source file correctly.
+\verb|\showCode| prints the source code, using minted for a pretty layout. It takes 4 arguments.
+Arg \#1 is the programming language,
+Arg \#2 is the source file name,
+Args \#3 and \#4 are the first and last line to show (optional).
+If the source file name does not exist, you will get a red and bold error message. For example:
+\begin{verbatim}\showCode{R}{Sim23.R}
+\end{verbatim}
+\showCode{R}{Sim23.R}
+\noindent
+In contrast, when the file exists, as in this example
+\begin{verbatim}\showCode{R}{paper/supplement/Code/code1.R}
+\end{verbatim}
+the file will be shown correctly:
+\showCode{R}{paper/supplement/Code/code1.R}
+\egroup
+
+\cause\bgroup
+If the programming language is misspecified or not recognized by minted or fvextra, the code highlighting may not be shown correctly.
+\begin{verbatim}\showCode{matlab}{paper/supplement/Code/code1.R}
+\end{verbatim}
+\showCode{matlab}{paper/supplement/Code/code1.R}
+\egroup
+
+\cause\bgroup
+If the line number in Arg \#3 exceeds the actual number of lines in the code, the code box will be empty, and the \LaTeX~ compiler will show an error message in its log file (`Empty verbatim environment'). For example:
+\begin{verbatim}\showCode{R}{paper/supplement/Code/code1.R}[6][8]
+\end{verbatim}
+% \showCode{R}{paper/supplement/Code/code1.R}[6][8]
+% \vspace{-2em}
+\noindent Some \LaTeX~ compilers will stop the compilation when they encounter `Empty verbatim environment' but will allow you to manually continue the compilation (and the generated pdf will contain an empty box with no code in it.)
+
+\noindent If the number in Arg. \#4 is greater than the number of lines in the file, minted will show the code up to the last line (so this misspecification is harmless).
+\begin{verbatim}\showCode{R}{paper/supplement/Code/code1.R}[4][8]
+\end{verbatim}
+\showCode{R}{paper/supplement/Code/code1.R}[4][8]
+\egroup
+
+\cmnt{Remember that the compiler is case-sensitive, so test.R is not the same as Test.R.}
+
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\prob{Errors when running code.}
+\cause\bgroup
+In batch-mode with \verb|\runExtCode|, if the source file name does not exist, you will get a red and bold error message:\\
+\verb|\runExtCode{julia}{test2.jl}{test2}|\\
+\runExtCode{julia}{test2.jl}{test2}\\
+Again, check for spelling errors in the file name, which is the most common reason for such problems.\\
+
+\noindent Similarly, when using the \textit{server-mode} of runcode, we can use the shortcuts to R, Julia, Python, or Matlab instead of \verb|\runExtCode|. The usage is similar, but the language name is inferred from the command. For example, we can have:\\
+\verb|\runR{paper/supplement/Code/code1.R}{testWithrunR}|
+\runR{paper/supplement/Code/code1.R}{testWithrunR}\\
+If the source code file doesn't exist, we get an error message as with \verb|\runExtCode|\\
+\verb|\runJulia{test2.jl}{test2}|\\
+\runJulia{test2.jl}{test2}\\
+\egroup
+
+\cause\bgroup
+Check that the correct executable is used, since \verb|\runExtCode| requires the specific program and command line arguments. For example, using R as the executable will not work in the following example:\\
+\verb|\runExtCode{R}{paper/supplement/Code/code1.R}{testWithR}|\\
+%\runExtCode{R}{paper/supplement/Code/code1.R}{testWithR}
+It will create the file tmp/testWithR.tex, and in it you will see\\
+\verb|ARGUMENT 'paper/supplement/Code/code1.R' __ignored__|\\
+This is a fatal error -- the compiler will get stuck because it will wait for the code to finish, and the compilation process will have to be terminated by the user.
+\noindent
+The correct way to use \verb|\runExtCode| with R in batch-mode is\\
+\verb|\runExtCode{Rscript --save --restore}{paper/supplement/Code/code1.R}{test}|\\
+See the package's documentation for more working examples.\\
+\egroup
+
+
+\cause\bgroup
+Check for syntax errors int the code.
+In the \textit{server-mode} only, \verb|\inln|, \verb|\inlnR|, \verb|\inlnJulia|, \verb|\inlnPython|, and \verb|\inlnMatlab| commands can be used to execute short source code and embed the resulting output within the text. It takes 3 arguments.
+Arg \#1 is the executable program;
+Arg \#2 is the source code
+Arg \#3 is the type output (if skipped or with empty value the default type is inline; vbox = verbatim in a box).
+
+\noindent If the code contains a syntax error, the error produced by the statistical software will be embedded in the text. For example, if we use Factorial, instead of the real function (factorial) we get an error message:\\
+\verb|The factorial of 6 is \inlnR{```cat(Factorial(6))```}.|\\
+would produce the following:\\
+The factorial of 6 is \inlnR{```cat(Factorial(6))```}.\\
+
+\noindent Such errors are not due to \LaTeX~ syntax or compilation, so runcode doesn't highlight them. Automatically identifying and highlighting such errors would require case-by-case analysis of the output of specific command-line tools. For now, it's up to the user to check the code before it is embedded in the tex document, and to check the output after the compilation.
+\egroup
+
+
+\cmnt\bgroup
+Recall that \verb|\runExtCode| which is used to run an external code takes 4 arguments:
+Arg \#1 is the executable program,
+Arg \#2 is the source file name,
+Arg \#3 is the output file name (optional - if not given, the counter
+ codeOutput is used).
+Arg \#4 controls when to run the code (optional - if not given, it listens
+ to \verb|\runcode|; run = force the code to run; cache or anything else =
+ use cache).\\
+The first argument can be \textit{any} command-line executable, including user-defined program names (compiled code, aliases, etc.). Because of that, we do not perform validity check before trying to execute it.
+For example, the following will not produce any error message:\\
+\verb|\runExtCode{C}{test.R}{}|\\
+but it will be possible to see an empty file in the tmp folder. This will be obvious to the user once the \verb|\includeOutput| command is executed in order to embed results in the compiled pdf document.
+\egroup
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\prob{Output is not produced, or unexpected/incorrect results are shown.}
+\cause\bgroup
+This could happen due to incorrect usage of the \verb|\includeOutput| function, which is used to embed the output from executed code. It takes 2 arguments:
+Arg \#1 is the output file name (optional - if not given, the counter codeOutput is used).
+Arg \#2 is the optional type output with default "vbox" (vbox = verbatim in a box, tex = pure latex, or inline).
+For example, if we run the code\\
+\verb|\runR{paper/supplement/Code/code1.R}{testWithrunR}|
+\runR{paper/supplement/Code/code1.R}{testWithrunR}\\
+\noindent
+Then to see the output, the correct usage is\\
+\verb|\includeOutput{testWithrunR}[vbox]|\\
+\includeOutput{testWithrunR}[vbox]
+
+\noindent Although the physical file is named tmp/testWithrunR.tex, we drop the tmp/ prefix and the .tex suffix. If we do include them, the file will not be found and we'll get an error message:\\
+\verb|\includeOutput{testWithrunR.tex}[vbox]|
+\includeOutput{testWithrunR.tex}[vbox]
+\egroup
+
+\cmnt\bgroup
+If anything other than vbox, tex, or inline is provided in the square brackets when using \verb|\includeOutput|, the output will be embedded in the document as plain text. While no error or warning is raised, this may cause problems in the compilation of the tex file and therefore should be avoided. (For example, if the output contains underscores then the compiler will report an error because it would appear that math symbols are used in text mode).\\
+\egroup
+
+
+\cause\bgroup
+When using one of the \verb|inln| functions, the code does not produce any output.
+In some cases it is perfectly fine if embedded code does not produce output, but when using \verb|\inln| this is not the case, so runcode checks if the command used within \verb|\inln| produced a zero-byte output file. If it did, runcode will show an appropriate message, like in the following example. Note that the reason no output is produced is that file.csv does not exist.\\
+\verb|The number of columns is \inlnR{```dat <- read.csv("file.csv"); cat(ncol(dat))```}.|\\
+This will result in:\\
+The number of columns is \inlnR{```dat <- read.csv("file.csv"); cat(ncol(dat))```}.\\
+\egroup
+
+\cause\bgroup
+When using one of the \verb|inln| functions, more than one line of output is produced by the code.
+The \verb|\inln| commands are designed to put a single string in a line, so the code which produces the output should not include a new line. For example, the following is incorrect:\\
+\verb|The factorial of 6 is \inlnR{```cat(factorial(6),"\\n")```}.|\\
+The factorial of 6 is \inlnR{```cat(factorial(6),"\\n")```}.
+\noindent
+The correct way is:\\
+\verb|The factorial of 6 is \inlnR{```cat(factorial(6))```}.|\\
+which produces the following:
+The factorial of 6 is \inlnR{```cat(factorial(6))```}.
+
+
+\noindent
+Similarly, if we want to print more than a one-line string, we should use the vbox option (or use \verb|\includeOutput|.) For example,\\
+\verb|A matrix \inlnR{```matrix(1:9,ncol=3,nrow=3)```}.|\\
+Will appear like this: A matrix \inlnR{```matrix(1:9,ncol=3,nrow=3)```}.
+\\
+\verb|A matrix \inlnR{```matrix(1:9,ncol=3,nrow=3)```}[vbox].|\\
+Will look better: A matrix \inlnR{```matrix(1:9,ncol=3,nrow=3)```}[vbox].
+\egroup
+
+
+\cause\bgroup
+This type of problem can also be due to invalid output in the cache files. If for some reason, the cache files contain special characters or an underscore in text-mode, then the output will be corrupted. It is recommended to clear the cache, and if server-mode is used to also restart the server. For example, suppose that the directory of the project is called proj, and we're using Python in server-mode. From the command line, run the following:
+\begin{Verbatim}
+cd proj
+rm -f proj.aux tmp/*.txt nohup.out proj.synctex.gz
+python3 -c 'from talk2stat.talk2stat import client; client("./","python","QUIT")'
+rm -f serverPIDpython.txt pythondebug.txt talk2stat.log
+\end{Verbatim}
+Then, recompile the project.\\
+\egroup
+
+
+\cause\bgroup
+Invalid, missing, or unexpected output can be due to having another runcode running on the system, but in another directory. If this happens, you will see a message in the log file saying that the server is already running. When multiple projects attempt to connect with the statistical software through the same port, only the first invocation will succeed but the subsequent ones will be connected to the first one. This will create unexpected results for all projects using the same port. Suppose your new project is B, and the runcode server of project A is still running and using the same port. In this case you may, for example,
+\begin{itemize}
+\item Accidentally overwrite variables in project A, or use the wrong ones in project B if they were also defined in A;
+\item Try to run code which is stored in project B, but you get an error message in the pdf file such as `\texttt{cannot open file 'mycode.R': No such file or directory}'. The reason for this error is that the other instance of the runcode server uses project A's base directory, and the file mycode.R is not in the right path.
+\end{itemize}
+To fix it, you can do one of the following:
+\begin{enumerate}
+\item configure each project to use another port to communicate with talk2stat (which will prevent any conflict between the projects), or,
+\item you can stop all instances of talk2stat running on the system before compiling your current project.
+\end{enumerate}
+To do the latter, find all the talk2stat processes, and find the corresponding directories. For example, suppose that multiple projects use talk2stat to communicate with Julia. From the command-line, do the following:
+\begin{Verbatim}
+cd proj
+ps -ef | grep talk2stat # get all the PIDs. E.g., 36797
+# on Mac:
+lsof -a -d cwd -p 36797
+# on Linux:
+pwdx 36797
+# lsof or pwdx will give you the directory name of the other projects which run talk2stat
+# cd to each directory, and run:
+python3 -c 'from talk2stat.talk2stat import client; client("./","julia","QUIT")'
+rm -f serverPIDjulia.txt juliadebug.txt talk2stat.log
+\end{Verbatim}
+\egroup
+
+
+\cause\bgroup
+If the correct output is in the files in tmp directory, but it's not showing in the pdf file, it can be due to the \LaTeX~ compiler's naming of temporary files. Usually, the auto-generated file names start with the main tex file name (e.g. if the main tex file is called troubleshoot.tex then runcode will create files such as \verb|troubleshoot_inln5.tex|). However, working with Overleaf we noticed that their compiler uses another convention for temporary file names. To prevent such problems, you can add the following in the preamble of the main document:
+\begin{Verbatim}
+\edef\TeXjobname{\jobname} % (this line is not really essential.)
+\edef\jobname{\detokenize{troubleshoot}}
+\end{Verbatim}
+\egroup
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+\prob{Working in server-mode, the server is stopped after each compilation.}
+\cause\bgroup
+If you are using the server-mode, be aware that some editors terminate all child processes at the end of \LaTeX compilation. For example, Emacs with Auctex behaves this way. For this case, use the nohup option, and the server will not be terminated by the parent process.\\
+If you want the server to be stopped after each compilation (regardless of the editor you are using), use the stopserver option. While you are compiling the tex document often, you may want to keep the server side running in order to save time during initialization, and to maintain the variables and results already in memory. However, it is a good idea to use the stopserver option when you are done, just to prevent any conflicts (see above).\\
+It's recommended to check that port numbers are unique, and when a project is not expected to be compiled for a while to enable the stopserver option.
+\egroup
+
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+\prob{The process seems to hang during code execution when the \LaTeX~ document is compiled.}
+\cause\bgroup
+We mentioned that code being sent to the software must be syntactically valid. In addition, keep in mind that the server waits for complete commands. So, for example, if we try\\
+\verb|The factorial of 6 is \inlnR{```cat(factorial(6)```}.|\\
+it will cause the server to hang because it awaits the closing parenthesis. Eventually, it will time out but the code cannot be executed, so the desired output will not be produced, and an error message will replace the output, as in the following example. The timeout interval is set in the config files for R, Julia, Python, and Matlab.
+\verb|The factorial of 6 is \inlnR{```cat(factorial(6)```}.|\\
+The factorial of 6 is \inlnR{```cat(factorial(6)```}.\\
+In this example the cat statement is missing a closing parenthesis.\\
+\egroup
+
+
+
+\end{document}
+
+
diff --git a/Master/texmf-dist/tex/latex/runcode/runcode.sty b/Master/texmf-dist/tex/latex/runcode/runcode.sty
index 1a44d5a5eaf..27202b469ad 100644
--- a/Master/texmf-dist/tex/latex/runcode/runcode.sty
+++ b/Master/texmf-dist/tex/latex/runcode/runcode.sty
@@ -4,6 +4,8 @@
%
% This package is based on an ongoing work by Haim Bar and HaiYing Wang, and comments and questions are welcome!
+\ProvidesPackage{runcode}[2022/08/10 runcode v1.6]
+
\newif\ifruncode
% Change to \runcodefalse if you want to suspend code execution
\runcodetrue
@@ -14,6 +16,11 @@
\mintedtrue
\DeclareOption{nominted}{\mintedfalse}
+\newif\ifreducedspace
+\reducedspacefalse
+\DeclareOption{reducedspace}{\reducedspacetrue}
+
+
% 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.
\newif\ifnotnohup
\notnohuptrue
@@ -27,7 +34,7 @@
\immediate\write\tempfile{[SERVERCONFIG]}
\immediate\write\tempfile{PORT = 65432}
\immediate\write\tempfile{DEBUGFILE = Rdebug.txt}
- \immediate\write\tempfile{PIPETIMEOUT = 300}
+ \immediate\write\tempfile{PIPETIMEOUT = 60}
\immediate\closeout\tempfile
}
% Start the server. Need to run just once. Can comment out after the first
@@ -47,7 +54,7 @@
\immediate\write\tempfile{[SERVERCONFIG]}
\immediate\write\tempfile{PORT = 65431}
\immediate\write\tempfile{DEBUGFILE = juliadebug.txt}
- \immediate\write\tempfile{PIPETIMEOUT = 300}
+ \immediate\write\tempfile{PIPETIMEOUT = 60}
\immediate\closeout\tempfile
}
% Start the server. Need to run just once. Can comment out after the first
@@ -67,7 +74,7 @@
\immediate\write\tempfile{[SERVERCONFIG]}
\immediate\write\tempfile{PORT = 65430}
\immediate\write\tempfile{DEBUGFILE = matlabdebug.txt}
- \immediate\write\tempfile{PIPETIMEOUT = 300}
+ \immediate\write\tempfile{PIPETIMEOUT = 60}
\immediate\closeout\tempfile
}
% Start the server. Need to run just once. Can comment out after the first
@@ -87,7 +94,7 @@
\immediate\write\tempfile{[SERVERCONFIG]}
\immediate\write\tempfile{PORT = 65433}
\immediate\write\tempfile{DEBUGFILE = pythondebug.txt}
- \immediate\write\tempfile{PIPETIMEOUT = 300}
+ \immediate\write\tempfile{PIPETIMEOUT = 60}
\immediate\closeout\tempfile
}
% Start the server. Need to run just once. Can comment out after the first
@@ -102,10 +109,18 @@
\DeclareOption{stopserver}{
\AtEndDocument{
%% stop the server when the pdf compilation is done.
- \immediate\write18{python3 -c 'from talk2stat.talk2stat import client; client("./","R","QUIT")'}
- \immediate\write18{python3 -c 'from talk2stat.talk2stat import client; client("./","julia","QUIT")'}
- \immediate\write18{python3 -c 'from talk2stat.talk2stat import client; client("./","matlab","QUIT")'}
- \immediate\write18{python3 -c 'from talk2stat.talk2stat import client; client("./","python","QUIT")'}
+ \IfFileExists{R.config}{
+ \immediate\write18{python3 -c 'from talk2stat.talk2stat import client; client("./","R","QUIT")'}
+ }{}
+ \IfFileExists{julia.config}{
+ \immediate\write18{python3 -c 'from talk2stat.talk2stat import client; client("./","julia","QUIT")'}
+ }{}
+ \IfFileExists{matlab.config}{
+ \immediate\write18{python3 -c 'from talk2stat.talk2stat import client; client("./","matlab","QUIT")'}
+ }{}
+ \IfFileExists{python.config}{
+ \immediate\write18{python3 -c 'from talk2stat.talk2stat import client; client("./","python","QUIT")'}
+ }{}
}}
\ProcessOptions*
@@ -129,7 +144,7 @@
\usepackage{fvextra}
\fi
-\immediate\write18{mkdir tmp}
+\immediate\write18{mkdir -p tmp}
\definecolor{bg}{rgb}{0.95,0.95,0.95} % code block background color
@@ -173,16 +188,20 @@
\ifthenelse{\isempty{#3}}{
\ifminted
\inputminted{#1}{#2}
- \vspace{-\medskipamount}
- \vspace{-\baselineskip}
+ \ifreducedspace
+ \vspace{-\medskipamount}
+ \vspace{-\baselineskip}
+ \fi
\else
\VerbatimInput[fontsize=\footnotesize,linenos=true,frame=single,breaklines]{#2}
\fi
}{
\ifminted
\inputminted[firstline=#3, lastline=#4, firstnumber=1]{#1}{#2}
- \vspace{-\medskipamount}
- \vspace{-\baselineskip}
+ \ifreducedspace
+ \vspace{-\medskipamount}
+ \vspace{-\baselineskip}
+ \fi
\else
\VerbatimInput[fontsize=\footnotesize,linenos=true,frame=single,breaklines, firstline=#3, lastline=#4, firstnumber=1]{#2}
\fi
@@ -249,13 +268,13 @@
{\unskip\input{\tmpname}\unskip}
{\input{\tmpname}}}}
% if code execution disabled, and no cache:
- {\begin{tcolorbox}
+ {\begin{tcolorbox}[colback=red!5!white,colframe=red!75!black]
\textbf{Output file \tmpname~ not found}. Check the file name (it may be that the file name was given with the suffix .tex. If so, remove it). If the file name is correct the problem may be because code execution is disabled and no cache is available. If so, force the code to run again (using the [run] option).
\end{tcolorbox}}}
\NewDocumentCommand{\checkZeroBytes}{m}{
- \immediate\write18{python3 -c 'import os; print("ZERO BYTES IN OUTPUT", file=open("#1", "a")) if os.path.getsize("#1") == 0 else True'}
+ \immediate\write18{python3 -c 'import os; print("**ZERO BYTES IN OUTPUT**", file=open("#1", "a")) if os.path.getsize("#1") == 0 else True'}
}