Questions tagged [pythontex]
PythonTeX allows you to enter Python code within a LaTeX document, execute the code, and access its output in the original document.
169
questions
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{...
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}
...
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:/...
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=...
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 ...
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=!...
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 ...
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 ...
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....
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 ...
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 ...
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 ...
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....
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 ...
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{...
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
\...
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*}[...
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.
...
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:
...
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'...
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 ...
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/...
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 ...
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.
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{...
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/...
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}...
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 > ...
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 ...
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 ...
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 ...
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 ...
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. ...
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....
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 ...
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. ...
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 ...
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 (...
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 ...
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 ...
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 ...
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 ...
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 ...
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....
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{...
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 ...
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 ...
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 ...
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
\...
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 ...