PythonTeX allows you to enter Python code within a LaTeX document, execute the code, and access its output in the original document.
Questions tagged [pythontex]
168 questions
5
votes
1 answer
How can I make imports in pythontex which apply to all sessions?
How can I make imports in pythontex which apply to all sessions? Consider for example the following pseudocode. I want to have separate sessions sessionA and sessionB, but want to import in both sessions the numpy library. How can I globally do this…
student
- 29,003
4
votes
2 answers
Pythontex don't work ? why?
I'm working with Windows 8, TeX Live 2015, and Python 3.4. I'm a newbie in LaTeX!
The installation of pythontex seems to be ok. I verify if all the files are at the right place. I try to make pythontex work with this code:…
fred62
- 61
4
votes
1 answer
Typeset functions with PythonTeX and execute them in console afterwards
I have the following python source code:
def modulo(a, n):
return a % n
print(modulo(3, 10))
print(modulo(10, 10))
print(modulo(11, 10))
The first function definition gives a hint about the implementation and the calls below show exemplary…
meisterluk
- 210
3
votes
0 answers
Pass macro to \pyv
I use Pythontex for formatting Python source code. I store code in a macro. I need to pass this code to one of the Pythontex commands (e.g. \pyv) and get the formatted code.
Code:
\documentclass{article}
\usepackage{pythontex}
\begin{document}
…
Sergey Fill
- 31
3
votes
1 answer
Problem with Pythontex
I would like to use Pythontex. I am on Mac texlive2019, python 3.7 (anaconda) TeXShop V 4.31
I followed all that was written on the documentation for the installation but impossible to have the result…
habib
- 61
- 3
3
votes
0 answers
What kind of templating engines besides jinja can be used for latex?
I have started to create automated reports in latex using jinja, also looked at pylatex as well and was wondering what other templating engines are available for programatically generating latex documents.
I know that there are a decent amount of…
GrandFleet
- 336
3
votes
1 answer
Using pythontex inside itemize
\newcommand{\test}[2]{%
\begin{itemize}
\pyc{strs = u"#1".split(u"#2");}
\pyc{for s in strs: print("\item " + s);}
\end{itemize}
}
When using this command, I get the folowing output:
perhaps missing…
3
votes
1 answer
Py{} adds a none in the code
I have the following MWE using pythontex:
%& -shell-escape
\documentclass{article}
\usepackage{pythontex}
\newcommand{\printPython}[1]{
\py{print(r'Hello, #1')}%
\newline
}
\begin{document}
Say hello Python:
%\begin{python}%
%print r"Hello…
arc_lupus
- 1,781
2
votes
1 answer
Invoke Jupyter from within LaTeX
I'd like to be able to write a LaTeX document that contains blocks of code in any of the languages for which I've installed a Jupyter kernel, and have the LaTeX compilation run Jupyter's console on those code blocks and include their output, much…
Nathan
- 305
2
votes
2 answers
Pythontex : Input into a pyverbatim environment
With the package Pythontex, I want to input a Python file into a pyverbatim environment :
For example, I tried the code :
\begin{pyverbatim}
\input{file_1.py}
\end{pyverbatim}
where file_1.py is a Python file .
But I obtained as result:…
Xavier ANSIAUX
- 107
- 1
- 8
2
votes
1 answer
How to retrieve multiples variables separately with pythontex?
Edit
I found something, but not working as I would like under TikZ. Here is the code…
Stan
- 173
2
votes
2 answers
How can I access a float defined via \pgfmathsetmacro from pythontex?
How can I access a float variable defined via \pgfmathsetmacro from pythontex?
Something like:
\documentclass{article}
\usepackage[gobble=auto]{pythontex}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\a}{1.7}
…
student
- 29,003
2
votes
1 answer
pythonTeX not printing variable in pycode environment
I'm trying to print the value of str from the pycode environment, however, it doesn't work. Interestingly \pyc{print(str)} works. Can someone please show me how to get the pycode environment to…
Andrew
- 73
1
vote
1 answer
Forcing LaTeX to rerun the same code every time with pythontex
I do not know how to import a function from another file using pycode.
I have a file named csv_code.py with the following code,
import csv
def create_csv():
header = ['name', 'degree']
data = ['Mark', 6]
with open('degrees.csv', 'w',…
1
vote
1 answer
numpy generates an error in PythonTeX
My question : How come PythonTex works as long as I don't try to load numpy ?
In the simple code below for…
JeT
- 3,020