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
2 votes
1 answer
71 views

Issue with including data file in a LaTeX table using the tabularray package

I am facing difficulties in including the contents of an external file into a LaTeX table using the tabularray package. I am using the following LaTeX code: \documentclass{article} \usepackage{...
Luis Ferreira's user avatar
0 votes
1 answer
38 views

Repeated value in align environment with pythontex

In following MWE, I expect the value of Amb. Temp. to be 50 but it doesn't. \documentclass{article} \usepackage{mathtools} \usepackage{units} \usepackage{pythontex} \begin{document} \begin{pycode} ...
Bahman Mirzakhani's user avatar
2 votes
0 answers
60 views

Pythontex in TeXShop for MAC

I am trying to use Pythontex in TeXShop but my engine is not working, here is my pythontex engine #!/bin/zsh # For anaconda distribution of Python, use #PATH=~/anaconda/bin:/usr/bin:/bin:/usr/sbin:/...
Enzo Ben's user avatar
0 votes
0 answers
94 views

How to set up pythontex package in latex?

I am trying to learn pythontex but the commands and environments from pythontex do not show any output. I tried to run the following example from youtube (link: https://www.youtube.com/watch?v=...
AAYUSH K.C.'s user avatar
0 votes
1 answer
61 views

How to create a matrix with a loop performing pycode

Okay, so there are a bunch of questions that are SO close to what I am trying to sort out, but I can't find a combination of approaches to make this work (I am so sorry if this has been answered ...
jesse's user avatar
  • 205
1 vote
1 answer
113 views

latexmk with pythontex, lualatex and long name not working

I have the following latex file: \documentclass{article} \usepackage[keeptemps, depythontex, runall=false, fvextfile=55]{pythontex}%rerun=always, \begin{document} computed by python: \pys[sname]{1+1=!...
user2609605's user avatar
2 votes
1 answer
57 views

`pythontex` and `\subfigure`

pythontex causing error with \subfigure environment. I have to rewrite my dissertation with many figures and subfigures, of which some are plotted with python inside LaTeX (I had to give up the python ...
khaz's user avatar
  • 155
2 votes
2 answers
166 views

mwrep and pythontex -- is it possible to use

The question: possibility of using of working python scripts embedded in LaTeX. When I was using \usepackage{python}, it did wonders to my dissertation (although I am very new to LaTeX, but some ...
khaz's user avatar
  • 155
0 votes
2 answers
67 views

pythontex and xlop

first of all, I am sorry if this has been already answered, I can't find any anwser ! When I try to compile this MWE : % % % xelatex document.tex % % % pythontex document.tex % % % xelatex document....
silver's user avatar
  • 1
0 votes
1 answer
102 views

Package pythonimmediate

I'm trying to load and use the package pythonimmediate but I'm facing difficulties in identifying what's going wrong. I had python 3.7 installed through Anaconda distribution. It seems that the ...
Damien Gredat's user avatar
0 votes
1 answer
115 views

How to randomly select and plot a csv file from a folder

I have data1.csv, data2.csv, and data3.csv in a folder. I use pythontex to randomly select a number from 1 to 3. \begin{pycode} list = random.sample(range(1, 3), 3) select = list[0] \end{pycode} Then ...
Hana Enna's user avatar
0 votes
0 answers
45 views

How to run other programming languages within LaTeX? [duplicate]

Sometimes I want to use LaTeX for typesetting but leave complex calculations to another language, where LaTeX receives strings and numbers to print. Is it possible to insert code for other languages ...
itood9896's user avatar
0 votes
2 answers
73 views

automating vector math problem creation using csv data source

I'm a teacher, and I'm looking to automate some homework problem creation with vector algebra. I would like to use a csv file (which I can pre-process for input to tex) with the format: "question....
randomlogic78's user avatar
0 votes
0 answers
160 views

Insert Python code code into a tex file

Is it possible to in include some python code into a Tex file? the python code works fine I am just not sure if I can put it into Tex file and make it work, I know this isn't a typesetting problem but ...
Paul A's user avatar
  • 681
2 votes
2 answers
58 views

fncychap and pythontex compatibility

I'm trying to use pythontex and fncychap packages in the same document but, apparently, there is some sort of incompatibility. If I try to compile this file: \documentclass[11pt]{book}% \usepackage{...
Luis C. Pérez Tato.'s user avatar
0 votes
0 answers
40 views

Generate rows for tabularray with pyluatex [duplicate]

Following the suggestion from pythontex section Troubleshooting for the tabular environment, I have created following minimal example using pyluatex instead of pythontex: %! TeX program = lualatex \...
Hotschke's user avatar
  • 5,180
0 votes
0 answers
129 views

Variable not defined in pythontex

When I run pdflatex, pythontex, and pdflatex, pythontex raise the error: NameError: name x is not defined. But when I run the py file in Python, it doesn't give an error. MWE: \begin{filecontents*}[...
Bahman Mirzakhani's user avatar
1 vote
3 answers
113 views

How can I use the return value of a pycode method in an \ifnum in LaTeX?

I am trying to use TikZ combined with the pythontex and cancel package to draw a (clip of the) plane of the rational numbers where all the rational numbers with a gcd not equal to 1 are crossed out. ...
RenamedtoRenamed's user avatar
0 votes
2 answers
400 views

PythonTex Error : No such file or directory on VSCode

\documentclass{ltjsarticle} \usepackage{pythontex} \begin{pycode} def fizbuz(n): for i in range(1, n+1): if i % 3 == 0: print("fiz", end=' ') else: ...
nekko's user avatar
  • 3
1 vote
1 answer
151 views

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'...
Tereso del Río Almajano's user avatar
0 votes
1 answer
77 views

PythonTeX and pgffor (foreach)

I am trying to generate a list of examples using PythonTeX and pgffor but this doesn't seem to work ?! The same example is repeated 5 times instead of getting 20 different examples. What's wrong in ...
RajM's user avatar
  • 3
1 vote
1 answer
2k views

Pythontex Warning: "DeprecationWarning: invalid escape sequence \m"

When using pythontex with sagefamily like in the example below, I get the following warning: This is PythonTeX 0.18 ---- Messages for sage:default:default ---- /usr/local/texlive/2021/texmf-dist/...
Julia's user avatar
  • 1,616
0 votes
0 answers
153 views

import problem with pythontex

I compile the following tex file with pdflatex -interaction=nonstopmode and pythontex, but got an error. How can I fix this? I have also tried "from math import comb" but it said there is no ...
Taro's user avatar
  • 213
1 vote
2 answers
5k views

How would one print table outputs in python into latex?

So, Let's say I have outputs of the following form: How would one insert this output into latex? I have tried using verbatim but I didn't like the result I wanted.
Rodrigo's user avatar
  • 471
1 vote
1 answer
95 views

Create latex boolean from pythontex

I essentially want to do something like this. \documentclass{scrartcl} \usepackage{fontspec} \usepackage[gobble=auto]{pythontex} \usepackage{ifthen} \begin{document} \newboolean{tex_bool} \begin{...
Franz's user avatar
  • 165
1 vote
0 answers
70 views

pythontex puzzle [closed]

For large matrices it is too difficult for me to type the tikz matrix expression. I have written some code in Python that does that for me. The code prints out the tikz expression which I then copy/...
Ted Black's user avatar
  • 381
0 votes
1 answer
46 views

PythonTeX cannot modify header or footer

Using PythonTex 0.18 i cannot change the header or footer. I followed the solution in using-pythontex-py-with-fancyhdr but it still doesnt work. MWE: \documentclass[11pt]{article} \usepackage{fancyhdr}...
dangu's user avatar
  • 13
1 vote
1 answer
71 views

Pythontex compile with Sublime

I am trying to use Pythontex with Sublime Text editor. I have installed the Pythontex package from: https://ctan.org/pkg/pythontex?lang=en I have then set up Sublime by going to: Preferences > ...
Scott Crawshaw's user avatar
1 vote
0 answers
116 views

Installing pythontex for use with Sublime Text3

Having a little trouble getting my head around the proper installation of pythontex package. I've added it to the preamble in my thesis file and tried running with the example nested inside the pycode ...
Wolfe79's user avatar
  • 303
0 votes
0 answers
197 views

Using PythonTex in Lyx on a Mac

I would like to use PythonTex in Lyx on a Mac. I don't understand the intricacy of Lyx/Tex etc. I think I managed to install PythonLex by installing MacTex 2021 which also installed Tex Live Utility ...
Keith Sloan's user avatar
0 votes
1 answer
332 views

Pythontex Installation

I am trying to install pythontex on my computer. I am using TeXstudio as my editor. I don't know if what I've done so far is correct, and how much more I need to do. So far, I've downloaded these ...
Harry's user avatar
  • 149
0 votes
0 answers
333 views

Converting Latex format of Mathematical or scientific expressions to voice

Text format can easily be converted into speech. Is there a way to convert Mathematical latex expression into speech? For example $\frac{1+\sqrt{5}}{2}$ - The fraction with numerator 1 + square root ...
raghul's user avatar
  • 1
0 votes
0 answers
184 views

Compile PythonTeX using TexPad editor

I recently started using PythonTeX, but am struggling to streamline my workflow. I use the latest version of TexPad (Version 1.9.2) under macOS Mojave. I'm perfectly capable of compiling PythonTeX (v. ...
Bucherjo's user avatar
2 votes
1 answer
194 views

How to customize typeset code appearance with pythontex

I use pythontex to execute / display python code in LateX Document (with pdflatex) and this work great. However, when I type \begin{pyverbatim} import numpy as np import numpy.random as rd p=3.6 up=0....
M. Miguel-Brebion's user avatar
1 vote
1 answer
179 views

Create 1-TeX-file version of PythonTeX document

I use PythonTeX for a number of my articles, yet a number of journals request a single .tex file which they can compile with what I assume is just texlive and a bunch of packages. The problem being ...
TheChymera's user avatar
0 votes
1 answer
162 views

pgfplot axis is offset

I have a plot generated from tikzplotlib & pythontex that I'm working on in a standalone document, to include in a larger document. The offset is present in both documents, and I do not know why. ...
Émile Jetzer's user avatar
4 votes
1 answer
318 views

pythontex does not consider certain changes unless I delete its files folder?

In the past, I have asked a question about including multiple images through Python in a tex document and I was given a solution which worked great (Link to the old question). My new problem: Now I ...
owmal's user avatar
  • 325
0 votes
1 answer
318 views

Error converting from Rmarkdown to PDF LaTeX

I am using Rmarkdown using Rstudio to generate PDF documents via tex. In the markdown, I write the python code chunk for reproducibility. However, I get the following error. Quitting from lines 23-30 (...
Ranji Raj's user avatar
  • 149
1 vote
0 answers
214 views

How to run PythonTeX

I've been trying to get PythonTeX up and running on my system (Mac running Catalina) but it's not working and I can't figure out why. I think it's something to do with the fact that it doesn't create ...
generallyconfuzzled's user avatar
0 votes
1 answer
296 views

how to use pythontex inside a python virtual environment

is it possible to change the python interpreter for pythontex to a python virtual environment such as a conda venv? My python functions that I call with pythontex for my latex document depend on ...
Jimmy2027's user avatar
  • 301
0 votes
0 answers
64 views

tcolorbox in a sublevel of enumerate containing verbatim

I would like the codepy box defined below to start either: to a new line, or its width be reduced so that it does not overlap with number 1.1] How to do this ? When tcolorbox contains a verbatim ...
jowe_19's user avatar
  • 805
0 votes
1 answer
106 views

How to hide pythontex commands in the output?

The following code I am running in Cocalc. It is in a latex document with pythontex. The output looks like this. I would like to not show the input code which I highlighted in a pink box on the ...
kiwani's user avatar
  • 101
0 votes
0 answers
379 views

Non-existent Pygments content on input line "?? PythonTex ??" [duplicate]

I am trying to present my Python script in latex. I have tried using the pyverbatim environment and the \inputpygments package but neither works, with both yielding the error message "Package ...
R_Dax's user avatar
  • 101
1 vote
0 answers
127 views

How can I apply changes in a python file referenced by \inputpygments?

I have a LaTeX document with some Python code using pythontex and \inputpygments. If I change something in a Python file, which is included by \inputpygments, the changes do not appear in the document....
nameless-ruler's user avatar
6 votes
1 answer
291 views

pythontex not rendering pygments output under beamerswitch

The following beamer file compiles fine under the sequence pdflatex -shell-escape file pythontex file pdflatex -shell-escape file file.tex: \documentclass{beamer} \usepackage{pythontex} \begin{...
Andrew Swann's user avatar
  • 94.8k
4 votes
1 answer
238 views

Create a new environment to display a framed Python interactive session

I want to display an interactive Python session inside a box in BEAMER. As my presentation has many slides like this I thought it would be convenient to create a new environment, but when I try to ...
Tonechas's user avatar
  • 972
1 vote
1 answer
211 views

How to display code snippets incrementally?

I want to use BEAMER and PythonTEX to prepare a slideshow that contains a lot of code. When displaying a code snippet in console mode I would like to show one line at a time. I'm struggling to achieve ...
Tonechas's user avatar
  • 972
3 votes
1 answer
4k views

Generating a latex table with multiple column levels using python pandas

I'm trying to create a latex table using the to_latex function from pandas but don't manage to get to a good looking table with multiple column levels. When creating a dataframe in pandas with ...
Jimmy2027's user avatar
  • 301
2 votes
1 answer
578 views

Easy way to include multiple image files from file directory through Python code?

I am trying to include an unknown amount of image files with unknown file names in a document. My code is inspired by a comment on this answer: https://tex.stackexchange.com/a/53465/206040 \...
owmal's user avatar
  • 325
1 vote
1 answer
269 views

PythonTeX expansion of LaTeX macros [duplicate]

I found this post by the creator of PythonTeX himself. However, running the below code doesn't work for me; I get an error "Something's wrong--perhaps a missing \item. \end{pyblock}". I'm ...
aosborne's user avatar
  • 143