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
2 answers
42 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: ...
user avatar
  • 3
1 vote
1 answer
54 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'...
user avatar
0 votes
1 answer
26 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 ...
user avatar
  • 3
0 votes
0 answers
29 views

Having trouble compiling and running basic pythontex code

I am new to latex and python. I am trying to run a very simple pythontex program in VS Code in Windows 10. I am getting the error message (pop up) "Cannot read properties of undefined (reading '...
user avatar
0 votes
0 answers
53 views

Adding a caption to python code snippet

A similar question was asked here, but the solution given in the comments didn't work for me. I have a code snippet in the following format and I would like to add a caption to it. How can I do this? ...
user avatar
  • 105
1 vote
0 answers
67 views

Define a polynomial symbolically, then differentiate it to find its local maximum [closed]

For the following, how to symbolically construct the polynomial Te(Ne) = a*Ne^2 + b*Ne + c, then find its maximum by equating its derivative to zero. I would like to find how to do it using either lua ...
user avatar
  • 8,789
1 vote
1 answer
160 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/...
user avatar
  • 1,494
0 votes
0 answers
60 views

Latexmk -pvc not working when using pythontex

If I add automatic pythontex execution to my .latexmkrc file, the -pvc option doesn't stop working, i.e. doesn't seem to detect changes in the source file. My .latexmkrc looks like this: $pdf_mode = 1;...
user avatar
  • 1,494
0 votes
0 answers
63 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 ...
user avatar
  • 213
0 votes
1 answer
505 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.
user avatar
  • 299
1 vote
1 answer
68 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{...
user avatar
  • 15
1 vote
0 answers
54 views

pythontex puzzle

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/...
user avatar
  • 103
0 votes
1 answer
36 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}...
user avatar
  • 3
1 vote
0 answers
40 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 > ...
user avatar
0 votes
0 answers
19 views

Unable to compile with pythontex [duplicate]

I have both python 2 and python 3 on my mac but I cannot compile my tex file with pythontex. The following error showed up: Traceback (most recent call last): File "/Library/TeX/texbin/...
user avatar
0 votes
0 answers
23 views

Import graphviz with pythontex

The python package lolviz produce graphviz pictures. We can view the picture by using g.view(). How can I print easily this output in my latex document by using Pythontex ? \documentclass[a4paper]{...
user avatar
  • 695
1 vote
0 answers
50 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 ...
user avatar
  • 173
0 votes
0 answers
63 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 ...
user avatar
0 votes
1 answer
102 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 ...
user avatar
  • 139
0 votes
0 answers
144 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 ...
user avatar
  • 1
0 votes
0 answers
112 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. ...
user avatar
1 vote
1 answer
86 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....
user avatar
1 vote
1 answer
117 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 ...
user avatar
0 votes
1 answer
46 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. ...
user avatar
4 votes
1 answer
169 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 ...
user avatar
  • 303
0 votes
1 answer
173 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 (...
user avatar
  • 115
1 vote
0 answers
124 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 ...
user avatar
0 votes
1 answer
114 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 ...
user avatar
  • 271
0 votes
0 answers
47 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 ...
user avatar
  • 695
0 votes
1 answer
61 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 ...
user avatar
  • 101
0 votes
0 answers
376 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 ...
user avatar
  • 101
1 vote
0 answers
75 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....
user avatar
5 votes
1 answer
212 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{...
user avatar
4 votes
1 answer
164 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 ...
user avatar
  • 950
1 vote
1 answer
128 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 ...
user avatar
  • 950
2 votes
1 answer
2k 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 ...
user avatar
  • 271
2 votes
1 answer
301 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 \...
user avatar
  • 303
1 vote
1 answer
165 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 ...
user avatar
  • 143
1 vote
1 answer
131 views

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 instance MWE \documentclass[12pt,a4paper]{article} \usepackage[utf8]{inputenc} \usepackage[...
user avatar
  • 2,495
1 vote
0 answers
53 views

Specify a dependency with latexmk and -output-directory

I'm using pythontex and I call \pyc{import * from functions}. This works fine, but when I used -output-directory, I need functions.py to get copied to the specified $out_dir before the build begins. ...
user avatar
1 vote
1 answer
354 views

Pythontex in TeXShop

I use TeXShop version 4.51 on macOS Catalina version 10.15.7. Followed the README.pdf titled "The Pythontex engine by Richard Koch" Downloaded anaconda from https://www.anaconda.com/...
user avatar
2 votes
1 answer
3k views

How to automatically convert a LaTeX math-mode equation into Python / numpy code?

Mathpix converts scanned formulas into LaTeX math code. Is there a similar tool that automatically converts scanned formulas or LaTeX math-mode equations (code) into python and numpy code?
user avatar
0 votes
0 answers
146 views

How add accents in pylatex?

Hi I'm starting to use pylatex. I'm trying to generate a pdf using the code below but just works when I remove the accent from the word información but if I do not remove it promts an Error. ...
user avatar
0 votes
0 answers
146 views

Using special characters ($, % etc.) in PythonTeX

I am writing a LaTeX document that retrieves values from defined ranges in a spreadsheet. I have a Python function that I know works (it works in VS Code). \documentclass{article} \usepackage{...
user avatar
0 votes
1 answer
97 views

Automatically generating pdf files from multiple latex files

I generate 50 similar latex files through python. Now I need all these files as pdfs. Is there a way to do this automatically in some way? The file names are Version 1, ..., Version 50. Example file: \...
user avatar
1 vote
1 answer
284 views

Default verbatim styles for pythontex

When using \printpythontex and the output verbatim, I'd like to set a default styling. For example: \documentclass{article} \usepackage[usefamily={jl,julia,juliacon},autoprint=false,autostdout=false,...
user avatar
0 votes
0 answers
114 views

How does PythonTeX work precisely "under the hood"?

PythonTeX requires for correct typesetting code and its output at least 3 step compilation: (lua/pdf/xe)latex pythontex (lua/pdf/xe)latex On Windows 10, the first run creates (among others) file \...
user avatar
0 votes
0 answers
113 views

Pythontex: Only run the modified code

I use \pyc{python code} to print matplotlib plots to pdf. I have many such huge plots within a document. Recently noticed that, though I am running pythontex without rerun=always option, all the ...
user avatar
  • 984
1 vote
1 answer
3k views

How to return latex as string from Python back to Latex document using pythontex package

I know how to use basic pythontex with single variables. But now I am trying to do something more than basic. I'll explain what the problem is, then given MWE below. To run the MWE requires having ...
user avatar
  • 18.3k
2 votes
3 answers
286 views

How can one construct a macro that contains a pythontex or fancyvrb environment?

Goal: I want to create a command that executes pythontex code blocks from within a macro. Application: I have a macro that typesets some equations. I'd like for a side-effect of their use to be the ...
user avatar
  • 143