summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.tex')
-rw-r--r--Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.tex17
1 files changed, 13 insertions, 4 deletions
diff --git a/Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.tex b/Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.tex
index ffaf503914c..d6c03253508 100644
--- a/Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.tex
+++ b/Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.tex
@@ -15,7 +15,7 @@
\usepackage{url}
\title{The \emph{pyluatex} package}
\author{Tobias Enderle\\\url{https://github.com/tndrle/PyLuaTeX}}
-\date{v0.2.0 (2021/07/26)}
+\date{v0.3.0 (2021/08/07)}
\begin{document}
\maketitle
\raggedright
@@ -58,8 +58,6 @@ $\sqrt{371} = \py{math.sqrt(371)}$
\randint{2}{5}
\end{document}
\end{tcblisting}
-\end{enumerate}
-\begin{enumerate}
\item Compile using Lua\LaTeX{} (shell escape is required)
\begin{tcblisting}{breakable,listing only,
size=fbox,colframe=black!8,boxrule=3pt,colback=black!8}
@@ -178,6 +176,16 @@ For an example, see the Typesetting Code section.
\item \inlcode|pythonq|\\[0.5ex]
Same as the \inlcode|python| environment, but any output is suppressed.
\end{itemize}
+You can create your own environments based on the \inlcode|python| and \inlcode|pythonq| environments.
+However, since they are verbatim environments, you have to use the macro \inlcode|\PyLTVerbatimEnv|
+in your environment definition, e.g.
+\begin{tcblisting}{breakable,listing only,
+ size=fbox,colframe=black!8,boxrule=3pt,colback=black!8}
+\newenvironment{custompy}
+{\PyLTVerbatimEnv\begin{python}}
+{\end{python}}
+\end{tcblisting}
+
\section{Requirements}
\begin{itemize}
\item Lua\LaTeX{}
@@ -194,7 +202,7 @@ However, PyLuaTeX has a \textbf{code and output buffer} which you can use to cre
This provides a lot of flexibility for your typesetting.
After a PyLuaTeX macro or environment has been executed, the corresponding Python code and output can be accessed via the Lua functions \inlcode|pyluatex.get_last_code()| and \inlcode|pyluatex.get_last_output()|, respectively.
-Both functions return a Lua table\footnote{\url{https://www.lua.org/pil/2.5.html}} where each table item corresponds to a line of code or output.
+Both functions return a Lua table\footnote{\url{https://www.lua.org/pil/2.5.html}} (basically an array) where each table item corresponds to a line of code or output.
A simple example for typesetting code and output using the \textit{listings} package would be:
\begin{tcblisting}{breakable,listing only,
@@ -238,6 +246,7 @@ Notice that we use the \inlcode|pythonq| environment, which suppresses any outpu
After that, the custom macro \inlcode|\pytypeset| is responsible for typesetting the code and its output.
Using a different code listings package like \textit{minted}, or typesetting inline code is very easy.
+You can also define your own environments that combine Python code and typesetting.
See the \inlcode|typesetting-*.tex| examples in the \inlcode|example| folder.
\section{How It Works}