Questions tagged [python]

Python is a general-purpose, interpreted high-level programming language.

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

Three Latex tables into one table with three Panels (Python export)

I'm working with Python and exporting Tables to Latex. My research requires me to do a lot of tables, and I need to update them many times with different revisions. Hence, I would need to figure out a ...
user avatar
2 votes
2 answers
122 views

Removing frames in the 'Python' environment

I use the Python environment from package pythonhighlight for highlighting code syntax. However, the code is always framed. Is there a possibility to switch off the frame around the code? Here is my ...
user avatar
1 vote
1 answer
43 views

How to use Pweave(Python + LaTeX) in TeXstudio of Linux Mint?

intro.tex (Can be skipped...😬) I recently switched from Windows to Linux Mint and just began learning Python. I wanted to make notes/reports using $\LaTeX$ and Python. Having used RSweave for a ...
user avatar
1 vote
0 answers
23 views

Adding Vertical Lines for Indents with lstlisting (or other package)

I have some code that is formatted with the lstlistings package in LaTeX, which looks like: However, when putting in longer code it can be difficult (especially on page breaks) to know how far ...
user avatar
  • 111
0 votes
1 answer
70 views

Embedding python with f-strings [closed]

I am using python to create a random problem every time I compile the file input{|python3 0.py} Its content is something like import random a = random.randint(1,9) b = random.choice(["a",&...
user avatar
  • 213
1 vote
0 answers
49 views

Jupyter notebook to beamer

There are plenty of solutions to transform a RStudio script to Beamer. However, there are not solutions to transform a Jupyter notebook of Python to Beamer... Is there any automatic way to insert ...
user avatar
0 votes
0 answers
57 views

Integrate Python code into Latex

Hi I would like to display a code with Minted. I have written the following \documentclass[11pt]{article} \usepackage{minted} \usemintedstyle{fruity} \begin{document} \begin{minted}{python} import ...
user avatar
  • 105
0 votes
1 answer
52 views

Best way to automatically set tick precision in pgfplots?

I know that I can manually set precisions like so: x tick label style = {/pgf/number format/fixed, /pgf/number format/fixed zerofill, /pgf/number format/precision = 2}, y tick label style = {/pgf/...
user avatar
0 votes
0 answers
30 views

How to leave a space between two longtables and horizontal lines in both tables?

I was wondering how to add space between two tables generated by the code below. Also, \hline doesn't work when I use it in both loops but works if I use it only in one. f.write('\\rowcolor{colour10} ...
user avatar
  • 33
0 votes
1 answer
43 views

Blank space after equal-sign in Python-Code-Section of LaTeX-Dokument-PDF by using packages "listings" and "pythonhighlight"

Does anybody know how to set the packages "listings" and "pythonhighlight" for displaying one blank space before (this already works) and after an "=" (and maybe other ...
user avatar
  • 3
2 votes
0 answers
33 views

Changing the color of numbers and special words in listings for a Python snippet

I'm using the listings package to write a report where I report some code in Python that I used. I am not very familiar with listings and am having several problems. Specifically: I would like to ...
user avatar
1 vote
1 answer
75 views

Automatically adding images directly from python code (preferably using VSCode)

Imagine I have some python code that generates an image. e.g. import matplotlib.pyplot as plt import numpy as np # Data for plotting t = np.arange(0.0, 2.0, 0.01) s = 1 + np....
user avatar
1 vote
0 answers
68 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
0 votes
1 answer
33 views

Typeset python setter decorators with the listing package

I'm using the listing package to include my source files (Python) in my documentation but I'm having an issue with highlighting the setter decorators. Decorators such as @property or @dataclass are ...
user avatar
  • 339
0 votes
1 answer
53 views

How to make tcolorbox with minted Python take up the entire document by shrinking whitespace?

I want to make a tcolorbox with minted Python code similar to this answer, including the size/aspect-ratio of the box, but with an additional requirement. I would like the rendered tcolorbox to take ...
user avatar
  • 148
0 votes
0 answers
36 views

Python code shows outside figure, but not inside figure

I have defined the following newtcblisting: \newtcblisting{pythoncode}[2][]{ listing engine=minted, breakable, coltitle=CustomColorOne, colback=gray!25, colframe=CustomColorTwo, listing ...
user avatar
  • 148
2 votes
1 answer
83 views

begin{minted}{python} not showing in PDF

This question was asked ans answered here Minted \begin{minted}{...} KO but \inputminted OK. The problem was supposedly fixed with fancyvrb 4.1 but I have installed full TextLive+Texmaker (fancyvrb 4....
user avatar
0 votes
0 answers
65 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
1 vote
0 answers
70 views

Python syntax highlighting

Is there already a standard way to highlight Python source code with high quality like within the IDLE (i. e. with the IDLE colors and highlighting rules)? solutions based on lstlistings (like ...
user avatar
0 votes
1 answer
578 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
0 votes
0 answers
98 views

Add annotations on plot with tikz

I am trying to generate a plot from Python and add annotations (identification of the three phases in the plot, and add separation lines). I start with a Python plot: #!/usr/bin/env python3 import sys ...
user avatar
  • 1,087
1 vote
1 answer
28 views

Minted environment returning blank after compile

I want to display the following computer code in Latex: But when I compile I get nothing at all! \documentclass{beamer} \usetheme{Berkeley}%{Marburg} \pgfdeclarelayer{pre main} \...
user avatar
0 votes
0 answers
149 views

Error using svg2tikz: AttributeError: 'TikZPathExporter' object has no attribute 'svg'?

I am trying to turn an .svg file to a LaTeX document. I cloned the github repo for avg2tikz and followed the installation instuctions. After not getting this to work with inkscape I tried to use it ...
user avatar
1 vote
0 answers
209 views

How to install pdfcol.sty

I'm trying to download a jupyter notebook to a pdf and have downloaded almost all the various packages it said I needed. Most recently, I got the following error: ! LaTeX Error: File `pdfcol.sty' not ...
user avatar
  • 11
1 vote
1 answer
105 views

Spacing issues when using NiceMatrix in Manim

I am trying to incorporate nicematrix objects in a Manim video and I am getting some spacing issues. The code from manim import * class Chap8_Recap36b(Scene): def construct(self): # self....
user avatar
  • 197
0 votes
0 answers
32 views

Problem on minted package on Windows 10 Pycharm

I have a problem with minted package, because when I try to use it in my text editor (TeXmaker), it returns me the next error: "You must have `pygmentize' installed to use this package" ...
user avatar
1 vote
0 answers
84 views

Call python functions from within plasTeX?

I am trying to make web pages about matrices, using sympy (python library) to compute symbolic matrices. I would like to write LaTeX code with the sympy expressions embedded, in such a way that ...
user avatar
0 votes
0 answers
119 views

How do I use nicematrix package in Sphinx documentation?

I'm trying to incorporate nicematrix functionalities into my Sphinx documentation. I have MiKTeX and I've intalled the nicematrix package. In my conf.py file, I added this: latex_elements ={'preamble'...
user avatar
  • 1
5 votes
4 answers
156 views

verbatim columns of vectors in booktabs columns

After lots of calculation in Python, a Pandas DataFrame is created that has several vectors. Fortunately Pandas can export its table in booktabs format, but the "vectors" get aligned by ...
user avatar
1 vote
1 answer
127 views

Minted Python example inside beamer frames

I would like to include minted Python code examples in my Beamer slide decks. I found an example that worked outside the \frame environment. Perhaps that will be suitable for future reports/...
user avatar
  • 148
1 vote
2 answers
132 views

TeXworks: Minted cannot find file or directory

I cannot get minted running with TeXworks on Windows 10 and I dont know why... This is my .tex file: \documentclass{article} \usepackage{graphicx} \usepackage{minted} \begin{document} \begin{...
user avatar
0 votes
0 answers
29 views

Find difficulty in enumerating by Latex in Python markdown

Our professor asked us not to use raw html to reproduce the following text. I tried to use the following codes to achieve such enumeration format but failed. Could anyone give me some hint? Am I on ...
user avatar
  • 1
0 votes
0 answers
24 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
  • 705
0 votes
1 answer
142 views

Creating barcode using pylatex

I'm trying to create a python program that creates numerous pdfs each containing a unique barcode using pylatex. Is there a simple way to do this? Here is an example of how the latex document is being ...
user avatar
  • 103
1 vote
0 answers
75 views

Create font package to use custom vectorial symbols via FontForge

This question builds upon my attempt to include custom, vectorial, LaTeX symbols inside Python plots via tikz, which (so far) is failing due to the impossibility (my inability ?) to attach proper font ...
user avatar
  • 21
0 votes
0 answers
60 views

Table with large cell data and long table spanning over multiple page

I need to create a 2-column table with below requirements: Column 2 has large data which spans over 2-3 lines Entire table may span over 2-3 pages The table entries are stored in a dictionary and ...
user avatar
  • 23
0 votes
0 answers
65 views

How to upload pdf and tex file to the mysql database without saving it into the local system using pylatex and python

I want the pdf file and the tex files to be saved directly into the database without saving them into the local system using pylatex and python. Any idea how I can do that?
user avatar
0 votes
0 answers
65 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
1 vote
2 answers
161 views

remove line break introduced by python environment

Suppose in my LaTeX file I need to create a python environment to execute some python code which does not create any LaTeX code. The python environment would still create a (blank) minipage which ...
user avatar
0 votes
2 answers
344 views

matplotlib pgf backend with lualatex - non-math font does not change

When using Python's matplotlib to produce plots, I sometimes require the lualatex engine using the pgf backend for matplotlib when producing "heavier" plots like hexbin, otherwise the TeX ...
user avatar
0 votes
0 answers
46 views

Replace lines and compile latex files in loop using python

I have a LaTeX code in which there are multiple chapters that I compile individually. Sometimes I have to compile a lot of these files, and I'm trying to automate this process, instead of uncommenting,...
user avatar
0 votes
0 answers
147 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
1 vote
2 answers
811 views

How to populate Python's dictionary data into Latex's table?

I have the data filled up at run-time in the dictionary. Need help in populating this data to a table in Latex. Code snippet for table: f.write('\\end{itemize}\n') f.write('\\begin{table}[ht]') f....
user avatar
  • 23
0 votes
0 answers
56 views

include own *.sty file when running from command line

I am running pdflatex from inside the python script. Python project is inside venv and my terminal command is like abs\path\to\pdflatex.exe abs\path\to\file.tex but when run, it cannot find my *.sty ...
user avatar
  • 113
3 votes
1 answer
530 views

twinx x-ticklabels not showing properly when input to latex document

I have a plot with two datasets, using the same x-axis data, so I want to plot this using the twinx functionality in python's matplotlib. To typeset the resulting graph in my latex document that the ...
user avatar
  • 33
1 vote
1 answer
88 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
0 votes
1 answer
271 views

How do I remove the box around python code?

I am using \usepackage{pythonhighlight} for python code and this creates a box around the code by default. Is there a way to remove the box? \begin{python} def f(x): return x \end{python}
user avatar
  • 33
1 vote
1 answer
323 views

Draw anything in a figure using pylatex

I'm wondering to know how to draw some lines in a figure or and add some linewidth on an image but I've trying I have not get any solution. This is the code I'm trying: from pylatex import Document, ...
user avatar
5 votes
1 answer
2k views

Can I execute python code inside LaTeX

I come to you this time not with a bit of code but with a large question: Is there a simple way to run some python code inside my document ? I came across some options : Sage : Quite a heavy ...
user avatar
  • 1,100
1 vote
1 answer
162 views

Flowchart Tikz for Process with levels

i need a PDF with a huge Process and levels for the subprocesses. The idea is to make it with tikz, but i dont know how to build it simple and automatic. Something like this example and the package ...
user avatar
  • 179

1
2 3 4 5
9