Questions tagged [python]
Python is a general-purpose, interpreted high-level programming language.
434
questions
0
votes
2
answers
50
views
Executing python script or code using \input not working
Im trying to execute a python script from within LaTeX by means of using the \input command, however I get a strange error that I can't really understand. Im following the working example taken from ...
0
votes
0
answers
37
views
Packages ucs and hyperref don't get along under xelatex
I'm getting an "undefined control sequence" error for \UTFviii@loop whenever I use both the ucs package and the hyperref package under XeLaTeX (and LuaLaTeX). (I understand \UTFviii@loop has ...
0
votes
0
answers
55
views
Python from LaTeX: Strange Networkx/Graphviz error
It is hard to give a minimal example, because Python3 with some packages is needed. I want to call Python from LaTeX, here is an example how I want to do it (--shell-escape is needed):
\documentclass[]...
0
votes
1
answer
57
views
How to configure the Python library latexmake to run with luaLaTeX?
I am working on automated templates, and I want to use latexmake with luaLaTeX, as suggested in a comment on this question, where I attempted a similar setup with XeLaTeX. However, I am facing ...
0
votes
0
answers
29
views
SageTeX does not work when TABs are used as indents
I wrote two practically identical files that use SageTeX to determine whether a positive integer is odd or even. The first example uses tabs for indentation.
\documentclass{article}
\usepackage{...
1
vote
1
answer
48
views
Error With LaTeX (TeXStudio) Package "Pygmentize"
After downloading the Minted and Pygmentize packages for TeXstudio, I am experiencing an error:
File 'pygmentize.sty' not found. \begin.
Here is the code for my document so far:
\documentclass{...
0
votes
1
answer
53
views
Remove extra spaces and curly braces latex code in string Python (normalize string in python)
I want to normalize string in python. For example, I have a LaTeX code
str='{{{ \\dfrac{{3}}{{4}} + \\sqrt{3} }}}'
I want to get the string
str='{\\dfrac{3}{4}+\\sqrt{3}}'
Remove extra ...
0
votes
1
answer
130
views
Markdown using LaTeX: Quotation marks in PyCharm vs. Github
I'm used to typing typographically correct English quotation marks as follows:
``text goes here"
In usual LaTeX documents this will work, no questions asked. When I use Markdown in Jupyter ...
2
votes
0
answers
29
views
Set Python's decorators in some colour but keep @ as an operator unchanged
I am using listings for code formatting and colouring in a document I'm working on, including a lot of Python code. I would like for decorators to be displayed in a specific colour but for the @ ...
1
vote
0
answers
32
views
tcolorbox minted doesnot break python docstring
I try to produce boxed minted code in Python, and it does not break Python docstring. I have tried different break... options, unsuccessfully.
MVE as follows:
\documentclass{article}
\usepackage{...
0
votes
0
answers
45
views
PyLatex prints names of packages at the top of the document
When i am trying to compile the LaTeX template that i have in a file using PyLatex, pdf that is getting generated have names of packages used at the top of the document. What may be a reason of that? ...
2
votes
1
answer
67
views
Ticks scaling - How to change the common factor multiplier to an offset value?
I am plotting the following figure using Python and I obtain this render:
Here, Python is automatically adding an constant value offset (+9.192682e9) on the y axis to read more easily the data.
Now, ...
1
vote
0
answers
127
views
LaTex Jupyter Notebook "Undefined Control Sequence"
I am attempting to save down a Jupyter notebook to a PDF using LaTex. I just installed the latest version of LaTex through Jupyter terminal but when I run
jupyter nbconvert --to pdf mynotebook.ipynb
...
0
votes
1
answer
60
views
How can I export a txt table to latex? [duplicate]
I have txt file with table format, I did it in python but now I have to export this table to Latex but I don't know how. I'm not good at all in latex so I'll appreciate if you help me.
Thank you!
0
votes
0
answers
135
views
Modifying existing Latex code to put Python codes in the Cheatsheet
I want to make a cheatsheet for Pandas which has Python codes. I googled and tried to find a free online site that help to get built easily. I'm unable to find except overleaf which uses Latex codes ...
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 ...
1
vote
2
answers
1k
views
Package minted Error: You must have `pygmentize' installed to use this package, while Pygments is already installed?
Installed MacTex2023 on a new Mac and all is well except for a nagging issue with "pygmentize" that I've already installed. I cannot find how to adjust system to recognise the installed &...
2
votes
1
answer
177
views
LaTeX is not letting me add spaces in strings in lstlistings
I am trying to add some code to my document, but whenever there is a space inside a string in the code, it shows up with a bucket(?) thing. I have provided the code and the output below:
\...
1
vote
1
answer
104
views
Change font in minted Python
I'm using minted to include Python code in my document, but I want to change the font of the letters only in the annotations and make it look more like what is portrayed in Jupyter Notebook.
This is ...
1
vote
1
answer
82
views
How to add tikz images to a latex document created via sphinx
What is the best way of adding tikz images to a latex document created via sphinx. Is there some kind of specific library
4
votes
1
answer
56
views
noweave not respecting indentation
In the past, I have often used noweb for Python projects, but this time I get strange behavior: indentation is not respected in the weaved file. Here is a minimal example, using noweb 2 (version ...
0
votes
0
answers
100
views
How to make Sphinx use custom style file as default, and override Sphinx formatting?
i am using Sphinx to create multi-format documents, LaTeX pdf and html.
I am trying to get Sphinx to use my own custom, heavily-formatted style (.sty) file, but it looks like Sphinx is overriding the ...
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 ...
1
vote
1
answer
97
views
Unicode characters and subscripts in minted python
using Sympy and print I get the Unicode characters shown below. I am trying to display them in minted. I tried to create the individual characters using newunicodechar. This seem to work for π but the ...
0
votes
0
answers
40
views
Sagetex ignores indents if they are done in tabs insteads of spaces - how to make it recognize tabs?
The following examples are visually identical code. The only difference is that the indents were done differently. Four spaces were used in the first and a tab was used in the second.
1.
\...
3
votes
1
answer
153
views
Sage is unable to process .sagetex.sage file created from sagetex
This is a simple .tex file that defines a sage function p(n) that returns 2 raised to the power of n.
\documentclass{article}
\usepackage{sagetex}
\begin{document}
\begin{sagesilent}
def p(n):
...
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 ...
1
vote
2
answers
53
views
Import Information into Several Documents from a Master Document
Context: I'm a university lecturer and therefore facing the same tasks whenever I prepare for a new semester. One of them is creating course material with LaTeX which includes a syllabus, slides for ...
2
votes
1
answer
82
views
Add title bar to minted code display
I would like to know how to go about adding a title bar to a minted block of python code? This is an example of a title bar I would like to use:
I tried using the code from this solution but I could ...
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 ...
-1
votes
2
answers
219
views
Function to output latex table from dictionary [closed]
Does anyone know how I can get a dictionary from python into a format that I can paste into latex to create a two column table of keys & values? I'm pretty basic with python.
E.G. a function to ...
1
vote
1
answer
355
views
Jupyter In/Out style using minted instead of listing
In Jupyter In/Out without Overflowing the solution provided is excellent. I'm implementing it using the minted option in tcbuselibrary and I'm getting this extra whitespace at the beginning of my ...
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
1
answer
83
views
latex inserts $ after clearpage followed by fatal error [closed]
I've built a python program that runs a .tex file using pdflatex.
However whenever I run the file i get a fatal error:
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
[1{/var/...
1
vote
0
answers
397
views
Arabic text in python code in listings at latex
I'm writing python code in my latex file, but it contain some Arabic texts when I write it using listings in python the Arabic words don't appear!
\documentclass{article}
\usepackage{listings}
\begin{...
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
0
answers
81
views
Workflow to create calibration certificates in latex from excel files?
I have calibration data in excel format, and I need to produce calibration certificates from it. Currently, we just use a separate sheet in the excel file to pull values from the data sheet and then ...
2
votes
2
answers
273
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 ...
1
vote
2
answers
285
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 ...
0
votes
0
answers
183
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 ...
0
votes
1
answer
2k
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",&...
2
votes
1
answer
700
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 ...
1
vote
0
answers
326
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 ...
0
votes
1
answer
64
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/...
1
vote
1
answer
229
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 ...
2
votes
0
answers
87
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 ...
1
vote
1
answer
708
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....
0
votes
1
answer
103
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 ...
1
vote
1
answer
238
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 ...