summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/lualatex/pyluatex/example/typesetting-example.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/lualatex/pyluatex/example/typesetting-example.tex')
-rw-r--r--Master/texmf-dist/doc/lualatex/pyluatex/example/typesetting-example.tex43
1 files changed, 43 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/lualatex/pyluatex/example/typesetting-example.tex b/Master/texmf-dist/doc/lualatex/pyluatex/example/typesetting-example.tex
new file mode 100644
index 00000000000..7c6cc910154
--- /dev/null
+++ b/Master/texmf-dist/doc/lualatex/pyluatex/example/typesetting-example.tex
@@ -0,0 +1,43 @@
+%% Copyright 2021-2022 Tobias Enderle
+%%
+%% 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 2005/12/01 or later.
+
+\documentclass{article}
+
+\usepackage{pyluatex}
+\usepackage{listings}
+\usepackage{luacode}
+
+\begin{luacode}
+function pytypeset()
+ tex.print("\\begin{lstlisting}[language=Python]")
+ tex.print(pyluatex.get_last_code())
+ tex.print("\\end{lstlisting}")
+ tex.print("") -- ensure newline
+end
+\end{luacode}
+
+\newcommand*{\pytypeset}{%
+ \noindent\textbf{Input:}
+ \directlua{pytypeset()}
+ \textbf{Output:}
+ \begin{center}
+ \directlua{tex.print(pyluatex.get_last_output())}
+ \end{center}
+}
+
+\begin{document}
+
+\begin{pythonq}
+greeting = 'Hello PyLuaTeX!'
+print(greeting)
+\end{pythonq}
+\pytypeset
+
+\end{document}