Skip to main content

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
1 vote
1 answer
33 views

create exam paper using py

I want to contruct an exam paper in latex. I need a question library written in latex. For example, there are 10 questions in it. A latex code is required that randomly selects 3 of these 10 questions,...
MATIRMAK's user avatar
  • 113
0 votes
0 answers
131 views

Manim Latex error converting to dvi

I'm not able to use Latex on Manim due to an error converting dvi. I saw other post about this and I change my code but it still does not work. Here is my code : from manim import * class dvi_error(...
Paine Pice's user avatar
0 votes
5 answers
272 views

How to include result values in a LaTeX document?

We are often in the following situation: a lengthy (data analysis) computation spits out a bunch of result values. Imagine a Python or script or an R script doing some resource intensive calculations. ...
lumbric's user avatar
  • 4,279
0 votes
1 answer
109 views

Use python variables or arrays in latex for loop

I want to access the '\j'-th element of the array in the latex for loop. SyntaxError: unexpected character after line continuation character \usepackage[top=4cm,right=2.5cm,left=3cm,bottom=2.5cm]{...
Emmanuel Francisco Castro's user avatar
2 votes
1 answer
90 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
51 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
116 views

Pythontex in TeXShop for MAC [closed]

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
1 answer
75 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
  • 215
1 vote
1 answer
215 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
93 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
215 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
89 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
151 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
47 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
91 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
2 votes
2 answers
70 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
43 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,320
0 votes
0 answers
161 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
143 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
508 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
226 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
119 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
3k 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,658
0 votes
0 answers
169 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
  • 203
2 votes
3 answers
9k 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
  • 491
1 vote
1 answer
100 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
  • 175
1 vote
0 answers
83 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
  • 495
0 votes
1 answer
48 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
94 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
143 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
  • 313
0 votes
0 answers
278 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
432 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
437 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
208 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
206 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
220 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
242 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
379 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
382 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
  • 169
2 votes
0 answers
280 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
440 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
  • 331
0 votes
0 answers
79 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
  • 939
0 votes
1 answer
134 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
380 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
145 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
311 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
  • 96.1k
4 votes
1 answer
282 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
  • 976
1 vote
1 answer
222 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
  • 976
3 votes
1 answer
5k 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
  • 331
2 votes
1 answer
669 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