Questions tagged [pythontex]

PythonTeX al­lows you to en­ter Python code within a LaTeX doc­u­ment, ex­e­cute the code, and ac­cess its out­put in the orig­i­nal doc­u­ment.

Filter by
Sorted by
Tagged with
0
votes
0answers
43 views

Pythontex: imported .py file sync

I've managed to make Pythontex working with Latexmk, the problem is that whenever I make changes to an included python file, it's old state persists in Latex unless I delete the auxiliary files and ...
3
votes
0answers
31 views

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{...
0
votes
0answers
27 views

Pycode environment doesn't work while the \pyc{} commands does

I'm trying to use pythontex on Texmaker/TexLive. I've downloaded the pythontex package and executed the pythontex.ins file. I've configured the compilation in this way : lualatex --shell-escape -...
0
votes
1answer
58 views

MacOS : Latexmk together with Pythontex

I am a beginner in Latexmk. Pythontex works fine by typesetting with a shell, but I would like to test also with Latexmk. I have installed it with TexLive, and I have a lot of rules preinstalled, ...
0
votes
1answer
90 views

Is there any way to convert a .py script file (on Python) to LaTeX code?

In the same way you can convert a jupyter notebook file to .tex file by using nbconvert package, I was wondering if there exist an equivalent way to do the same stuff but with .py script file as input....
1
vote
0answers
17 views

Is it possible to have a section of code in the preamble evaluated last in pythontex?

I have a situation where a series of plots are generated using PythonTeX within my document, wherein they all append to a global "preamble" variable. I want to be able to print this variable into ...
0
votes
0answers
39 views

Pythontex error not compiling python

I have a full installation of Texlive 2019 and both 2.7 and 3.7 versions of Python installed. I want to compile the following simple project wich contains a python command inside pythontex environment....
3
votes
2answers
284 views

How to print a variable with underscore in its name?

This code works perfectly: % arara: pdflatex: { shell : yes } % arara: pythontex % arara: pdflatex: { shell : yes } \documentclass{article} \usepackage{filecontents} \begin{filecontents*}{provapd.txt}...
0
votes
0answers
31 views

Pythontex and input

I used pythontex since a year and I'd like to include and execute code with input commands (I teach python and for the moment I don't have access to the def structure...). Maybe it's not implemented ?...
2
votes
1answer
55 views

PythonTeX: Using LaTeX macros in pyblock

Is possible to use LaTeX macros in pythonTeX pyblock environment and use/store theyre output on python side of pythonTeX? Following MWE should completely illustrate my question: \documentclass[11pt]{...
0
votes
0answers
61 views

pythontex successfully installed, but nothing appearing with print statement

I believe that I have successfully installed pythontex; it appears as installed in the MiKTeX console, and when I enter pythontex --version in the console I see PythonTeX 0.17. I am using TeXStudio ...
2
votes
1answer
72 views

Number formatting in PythonTeX with `sage` family

I am trying to get a special number formatting in pythontex with sage family but it doesn't work. Here is an example which shows how it should look like and what I tried so far. How can I make it ...
0
votes
1answer
97 views

NumPy matrix multiplication with @ in pythontex

The following commands are working fine in Python 3.x: import numpy as np M = np.array([[1,2,3],[4,5,6]]) D = np.diag([1,2,3]) M@D But, when I use pythontex, I get an error with M@D. Do you know why?...
1
vote
1answer
47 views

PythonTeX connecting to .accdb with python module and making adjustment to the output

I am working on connecting TeX with MS Access database. Great option for my workflow seems to be PythonTeX, since that for beginner in TeX and Python, like me, it is pretty easy to use and work with (...
0
votes
0answers
212 views

pgfplot ; animate ; pythontex : a plot of a derivative

With the BIG help of @njsg (Nuno Silva) I made this plot. The goal is use it as a animation inside a beamer slide. \documentclass{standalone} \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{...
0
votes
0answers
84 views

Tikz: addplot error using pythontex

Please, help solve this issue. The python code have the objective of calculus the derivative of an expression f(x). If I uncomment the line %\addplot [domain=0:10, samples=100, color=blue ]{\pyc{...
1
vote
2answers
68 views

How can I put a pyblock in a box?

I'm learning using PythonTeX and I have a problem. I would like to put a pyblock inside a box on my document, I tried this two things, but TeXMaker never ends compiling Option 1: \documentclass{...
1
vote
1answer
112 views

Subfiles, pythontex and \pyverbatim -> standalone + pythontex

I would like to introduce some python using pythontex in some of my chapters. I'm using the package subfiles to have a master documents and some childs and it's very convenient for me, I would like to ...
0
votes
0answers
22 views

Create a rule for using arara together with texpad editor and pythontex/xelatex/bibtex

I am a beginner with Arara. I would like to create a rule for the following typesetting : xelatex -8bit -synctex=1 $1 / pythontex $1 / bibtex $1 / xelatex -8bit -synctex=1 $1 / xelatex -8bit -synctex=...
3
votes
2answers
258 views

How to let AUCTeX launch automatically pythontex.py script

I need to use the pythontex package that I find very useful if someone has to do some calculation before inserting the results in LaTeX. So Here is an example: \documentclass{article} \usepackage{...
0
votes
1answer
149 views

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 ...
0
votes
1answer
265 views

lstinputlisting Invalid UTF-8 byte sequence with regex in python file

I am trying to import a python file with an regex expression. I tried adding the \UseRawInputEncoding at the beginning, but I still get errors with Invalid Bytes. \lstinputlisting[caption={Dummy ...
0
votes
0answers
34 views

How to cache content generated within a latex environment?

I have a document that is created like this: \documentclass{article} \usepackage[pgfplots]{juliaplots} \begin{document} \begin{jlcode} x = [1,2,3] y = [2,4,1] plot(x, y) \end{jlcode} \...
1
vote
1answer
228 views

Problem getting pythontex to work with Julia

I was able to get pythontex to work fine with Python but am having errors when I try to use it with Julia. I am running on OSX 10.13.6 with updated texlive and using Texmaker. I am running this ...
0
votes
0answers
138 views

PythonTeX: importing/printing all the python files of a folder

I'm using Pythontex for my lecture notes. I have a lot of .py files containing classical scripts (simulations of random variable for example), which I use in many files. My aim is thus the following ...
0
votes
0answers
231 views

Pythontex couldnt find engine

I tried to use pythontex in my LaTeX Program. Therefore i installed MikTex an working with Texmaker. There i installed the pythontex-package (by installing it via usepackage). After running the ...
0
votes
0answers
82 views

PythonTex showing matrices in the document

I'm trying to plot a simple matrix in a LaTeX document but without success. I compile the .tex file, then pythontex.py, then the .tex file again, and it compiles without errors but the final document ...
0
votes
0answers
68 views

How to run a document containing both PythonTeX and BibTeX in one go on TeXstudio?

Let's say that I have the pythonbiblio.bib file that contains this: @misc{Einstein, author = "Albert Einstein", title = "The Art of the Calculus", year = "2042" } And my pythonbiblio.tex ...
0
votes
0answers
216 views

Convert Jupyter Notebook to Latex with margin handled automatically

Is there a way to convert Jupyter Notebook to .tex with margins being taken care automatically. I have some lines that overshoots the margin on LaTex. Is it possible to automatically put new line ...
2
votes
1answer
104 views

Pycode code inside exsheet question

I want to create a table inside of a exsheets question (or solution) (using data defined in another pycode environment outside of it). But this doesn't work. What did I do wrong and how can I make it ...
1
vote
0answers
48 views

How can I hide (or blur) some code in a pythontex environment?

My question is directly related to this one. Does there exists a solution for pythontex ? At least for the verbatim environment. More precisely, let us consider the following MWE : \documentclass[...
1
vote
1answer
111 views

how to pass section numbers to python in pythontex?

I am writing out some parameters to JSON files using pythontex, but would like to add context information in form of section numbers (for example \thesection or \thesubsubsection, perhaps also the ...
3
votes
0answers
65 views

Pysub the entire document

In pythontex the pysub environment provides a nice syntax to refer to python variables (for example !{a}) inside your latex code. Suppose you have only one pythontex session in your document. Is ...
1
vote
1answer
73 views

pythontex environments and savebox

I want to use the same code in several pythontex environments: \documentclass{article} \usepackage{pythontex} \begin{document} \begin{pyconsole} print('Hello \\LaTeX{} World!') \end{pyconsole} \...
1
vote
1answer
178 views

tikz \foreach to iterate over a python list via pythontex

I am using pythontex to read in a large python list from disk into my .tex file; I wish to use the \foreach command from the tikz package to do some typesetting for each of the items in the list. MWE ...
2
votes
1answer
374 views

Issue with Pythontex using a LaTeX editor (MacOS - Anaconda)

I just achieved a clean install of MacOS Mojave. I have reinstalled Pythontex with the help of TeX Live Utility. Python 3 is installed with Anaconda. The package works fine when the typesetting is ...
2
votes
1answer
512 views

Setting conda environment for pythontex in TexStudio

I am using Texstudio with a build configuration based on this question in order to run PythonTex and embed python code into my documents. This worked and I was able to use the \begin{pycode} and \end{...
1
vote
0answers
414 views

How to include figures using Pythontex

I try the solution of G.Poore (https://github.com/gpoore/pythontex/wiki/matplotlib) in order to include easily a lot of figures in a TeX document using Pythontex. Unfortunately I get the following ...
1
vote
0answers
121 views

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 ...
3
votes
0answers
128 views

UnicodeDecodeError pythontex

An error occurred when I try to compile the following minimal example with xelatex --8bit and pythontex. \documentclass[a4paper]{book} \usepackage{fontspec} \defaultfontfeatures{Ligatures=TeX} \...
1
vote
0answers
307 views

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 ...
0
votes
1answer
91 views

Pythontex and mdframed in an environment

I try to define an environment called "codeaux" printing a piece of python code inside a mdframed environment. After that my aim will be to redefine "codeaux" in a pyconsole version (pyblock/verbatim ...
1
vote
0answers
64 views

PythonTex stderr - error on line 364 [duplicate]

I am new to pythonTex. I get following error. I checked working of simple python code. However, when I try to import math within pycode it gives error. using code: \begin{pycode} import math from ...
1
vote
1answer
177 views

PythonTex stderr

I am new to pythontex. I could run simple python code. However, I get error with slightly complex things. The error I get is following: This is PythonTeX 0.16 ---- Messages for py:default:default ...
1
vote
1answer
588 views

Send tabular data to Latex

I need to send data from Python to Latex code. The data is tabular data, hence looping in such data in Latex would be tough. So, I thought creating a latex code in Python and adding it there would ...
4
votes
1answer
55 views

call \pygment with `#` or `%` character in tabularx environment

I have the following MWE : \documentclass{article} \usepackage{pythontex} \usepackage{tabularx} \begin{document} \begin{tabularx}{\linewidth}{X} \pygment{c}{#include <stdio.h>} \\ \end{...
1
vote
0answers
401 views

Interactive Plot with controls in the frame [closed]

I would like to know if there is any way to include a plot which can interactively change using slider controls in a Beamer presentation. For example, I would like to show the following ipython ...
1
vote
0answers
205 views

Create new command python

I want create a new command in python, in https://tex.stackexchange.com/a/234232/153360 add the command sage to pythontex. How can I change or add a command which output a string instead of a latex ...
2
votes
1answer
1k views

TeXmaker (MikTeX) using pythontex

I am trying to use pythontex with Texmaker 5.0.2 (MikTeX 2.9.6637). I use an example code provided by overleaf.com (see below). On overleaf.com the example code does compile without any problems. When ...
1
vote
0answers
101 views

I can't not run python tex in my document [closed]

His code not run \documentclass{article} \usepackage{pythontex} \begin{document} This is my code. \begin{pycode} a='andrey' print('Hi es ',a) \end{pycode} \end{document}