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

learn more… | top users | synonyms

37
votes
3answers
1k views

How to publish a package that includes scripts and/or executables?

I'm preparing to publish my first package, and am not sure about the best way to proceed. I understand the standard CTAN publishing approach, but I'm dealing with a somewhat atypical case since my ...
32
votes
7answers
3k views

What are the advantages of Lua over other scripting languages for a TeX implementation?

The question is inspired by Martin Schröder's answer to I am new to TeX. Should I use LaTeX, XeLaTeX, …? as well as my two previous questions on this forum: Automatic document update Generate LaTeX ...
21
votes
3answers
601 views

Best way to illustrate Keplers 2nd law with tikz

I am trying to visualize Keplers second law of planetary motion with tikz. I managed to do the following: \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} ...
20
votes
2answers
10k views

How to highlight Python syntax in LaTeX Listings \lstinputlistings command

I am using package listings to import my Python source code into my LaTeX document. I use the command \lstinputlistings. I have a Python source like class MyClass(Yourclass): def __init__(self, ...
18
votes
1answer
571 views

How to typeset programming code syntax with annotations?

If possible I would like to know how to this on latex/tikz to add this like (environment and graph) on my ebook. Thanks a lot!!! Code im trying to implement: \documentclass[11pt,fleqn]{book} ...
17
votes
4answers
773 views

Calculate prices

I want to calculate prices in a LaTex file. This means I want to add two numbers with exactly 2 decimal places and I want to multiply these values by an integer. An other thing is the output format. ...
15
votes
3answers
999 views

Automatic document update

As many of you I do quite a bit of teaching to make living. The worst part of the semester is usually beginning when I create and upload course Syllabi as well as the end of the semester when I ...
15
votes
1answer
951 views

Embedding Python in LaTeX - Hello example?

I found example of the using Python in LaTex, but unfortunately I have problem with it. Microsoft Windows [Version 6.2.9200] This is XeTeX, Version 3.1415926-2.5-0.9999.3 (MiKTeX 2.9 32 bit) ...
13
votes
5answers
3k views

Using Python within LaTeX and accessing its variables

I have used the python package to include Python in my LaTeX document which works fine. I am trying to access the Python variables/calculations outside of \begin{python} ... \end{python}, without ...
13
votes
1answer
2k views

Embedding python in tikz

I just discovered the python package, and I'm trying to use it in Tikz code. Unfortunately, this doesn't work: \documentclass[oneside]{memoir} \usepackage{pgfplots} \usepackage{python} ...
12
votes
0answers
1k views

Matplotlib and Python as the main TeX graphics engine [closed]

As many people here who do some scientific computing, I'm increasingly using Python as my main prototyping language in favor of MATLAB. A colleague of mine whose husband got me into Python approached ...
11
votes
6answers
3k views

Generate LaTeX Truth Table with Python Cheetah

While looking for code which can automatically generate truth table in LaTeX I stumbled on this Python generator. It appears that the code can be used from Cheetah's framework. Can anybody point me to ...
11
votes
1answer
4k views

MiKTeX and Perl scripts (and one Python script)

Again and again here on TeX.SX users of MiKTeX ask a question having a problem with a package or included program, where it turns out, that a Perl script is involved, in particular glossaries (because ...
9
votes
2answers
1k views

Set fonts in matplotlib graphs equal to tex document

I am writing my PhD in LaTeX and I am generating all my graphical content in Python with the matplotlib package. For my TeX document, I am using a math-supported font -- e.g. Kurier Light Condensed -- ...
9
votes
2answers
944 views

Pythontex workflow with LyX

I've recently learned about PythonTeX (Conference presentation). It's a tool that lets you execute python code in your LaTeX documents. This is useful for, e.g., creating matplotlib figures inside ...
8
votes
2answers
3k views

Python code in LaTeX document

I want to include some Python code into LaTex document, so I "imported" the listings package with \usepackage{listings} and \lstdefinelanguage{Python}{ keywords={typeof, null, catch, switch, in, ...
8
votes
3answers
2k views

LaTeX to HTML: PolyTeXnic and PlasTeX

I was stunned by the elegant appearance of the Tau manifesto page, for which the source is in LaTeX. The author used a home-made tool that he calls PolyTeXnic, but which he is not willing to release. ...
8
votes
1answer
435 views

PythonTeX: importing python files

I'm trying to import a personal python module using python tex, but pythontex doesn't find the module. My attempt: The LaTeX File: % !TEX TS-program = pythontex \documentclass[11pt]{article} ...
8
votes
0answers
179 views

LaTeX Visual Novel Engine: Does it exist?

Did anyone in the past use LaTeX to create a "visual novel" engine? I've been using http://www.renpy.org/ for rare presentations when I need functionality the beamer class in LaTeX doesn't easily ...
7
votes
2answers
265 views

Underscore in filenames in \textit{} imported from a python script

I'm trying to import the name of a result file from a python script and displaying it in the report. In the LaTeX template I have a bunch of variables defined as ${variablename}. The python script ...
6
votes
2answers
208 views

Automatically include a sequence of images

I want to include a sequence of images in Beamer (although it can be in another type of document). Something similar to the option Photo Album in LibreOffice and MS PowerPoint. What I did is to make ...
6
votes
1answer
461 views

Running a simple example with PythonTeX fails

Using the v 0.12 beta of PythonTeX I am trying to compile the following example: \documentclass[12pt]{scrartcl} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{pythontex} ...
6
votes
1answer
19 views

Inconsistent invocation of Python versions with pythontex

I'm getting what looks to me like anomalous behavior with the pythontex system. A minimal working example is the following: \documentclass{article} \usepackage[gobble=auto]{pythontex} ...
6
votes
1answer
1k views

Adding words to lstlisting for Python langaue

I wish to add a few keywords to some python code inserted into a latex document. I want to make 'True' & 'False' appear yellow and also some module calls such as 'ttk' appear red. I have tried ...
6
votes
2answers
223 views

Does anyone know an easy way to produce a table with cells spanning multiple pages using latex? [closed]

I'm looking into the possibility of using latex for programmatically generating PDFs from templates with placeholders and some textual data. The current solution I have is based on reportlab, and it ...
5
votes
1answer
506 views

Python code in LaTeX not running

The Latex/Python Project: Create in Latex a songbook from pdf files in a folder and make a toc. Problem: The code below is not running in Latex. Thanks to G.Poore I added the \verb command to ...
5
votes
1answer
147 views

Latex \newcommand with python code inside

I'm extremely new to Latex. I'm using python package to insert graphics in a loop. What I can not understand is how I can transform this code \documentclass{article} \usepackage{python} ...
5
votes
1answer
358 views

python.sty on TeX Live 2013 - Forbidden to open for writing error

I have a fresh install of TeX Live 2013 and am attempting to compile a file using the python package. Here is the relevant portion of the file \begin{python} print 'hi' \end{python} I've compiled ...
5
votes
1answer
474 views

How to match cmyk colors between matplotlib and LaTeX

I'm plotting something using matplotlib and I'm using the matplotlib.cm.rainbow colormap. I need to match the same colors in my LaTeX document, but I'm having a difficult time making the colors match ...
5
votes
1answer
231 views

pythontex - reading data from a file

This is about a file location problem while using pythontex (which works great!) I have some python code within \begin{pylabblock} \end{pylabblock} where I am reading in data from a file in the ...
4
votes
1answer
132 views

How to batch generate badges with a list of names?

I want to make a number of badges using LaTeX for the participants of a summer school. There are 40 or so people, so I don't want to manually change the name and compile and then print. I could think ...
4
votes
2answers
912 views

minted doesn't escape LaTeX code inside python docstring

How can I get minted to escape LaTeX code inside docstrings? Should I use some switch? \documentclass[a4paper,12pt]{article} \usepackage[italian]{babel} \usepackage[T1]{fontenc} ...
4
votes
2answers
2k views

Unable to use python.sty package

When compiling a .tex file that uses python.sty package and contains: \begin{python} ... \end{python} I keep getting an error: ./main.tex:33:I can't find file 'bin/main.py.out' \end{python} ...
4
votes
1answer
141 views

pythontex - How to choose the version of Python used?

I have two versions. How can I tell to pythontex the path to the Python3 to be used if it is possible ?
4
votes
1answer
149 views

How to let minted highlight a whole file from disk

I am using the minted package to highlight source code in LaTeX. It works well for a piece of code embedded in \begin{minted} ... \end{minted}. Now the question is if it is possible to highlight a ...
4
votes
1answer
359 views

Latex-Python combination not running on a mac

I am a beginner in Latex/Python and try to run the file below on my Mac (10.8.4 - latest MacTex). This is just a test file and it is not running. Python is running in the console and I have copied ...
4
votes
1answer
133 views

Pass (La)TeX-Length as function argument using pythontex

I'm trying to pass a LaTeX-Length (\textwidth) to a python function specified in an pyblock-environment provided by the pythontex-package. Running pythontex gives me an error message, that does not ...
4
votes
1answer
174 views

tcolorbox minted library with python3 non-determinism

Later versions of the package tcolorbox allows formatting source code with its minted library (which uses the minted package). When a document is compiled, a temporary file with extension .pyg is ...
4
votes
1answer
39 views

How to make breaklines the result from PythonTeX ?

I try make a document with use PythonTeX like this : \documentclass[a4paper, 12pt]{article} \usepackage{pythontex} \usepackage{fullpage} \begin{document} \begin{verbatim} \py{2014/2009} ...
4
votes
1answer
917 views

Preventing Ångström symbol being italicised in pythontex

I'm trying to make a plot in a tex document within pythontex and I set the label within pycode tags to be self.label = r'A: {0} B: {1:.0f}$\AA$'.format(self.aaa,self.bbb) I don't want the Ångström ...
4
votes
1answer
513 views

Page a day calendar problems

I am really new to the whole LaTeX thing, but it really interests me, so I'd like to learn more about it. I am also looking mostly to do just words, maybe a picture here and there but i just want ...
4
votes
0answers
3k views

Programmatically generating LaTeX with Python [closed]

I'm fairly new to LaTeX and I want to generate some reports using Python. Here is some code that creates a simple table. After coding this up I began to wonder if there isn't a better way to do ...
3
votes
1answer
57 views

How can I use a LaTeX .sty file to get output from a Python file?

I'm currently working on a package that supposedly takes the output of a function in a Python script, and adds it to the PDF. For example, one function may scrape data from a website automatically, so ...
3
votes
1answer
356 views

String Formatting when using PythonTex

First of all, many thanks to Geoffrey Poore, the creator of PythonTex. PythonTeX is awesome. I am trying to use it for the first time and really like what it can do. I am having some trouble with ...
3
votes
1answer
295 views

Is there a PythonTex equivalent to \Sexpr{} in R?

I started to use the excellent PythonTex package to write reproducible reports but can't seem to get it to evaluate Python code inside a LaTeX command. R has Sweave & knitr which provide the ...
3
votes
1answer
39 views

python environment works with animate for single frames but not multiframe

I am trying to achieve some complicated animations with the animate and python packages. I can use the python environment within an animate environment for single frames, for instance: ...
3
votes
1answer
67 views

Problem with listings package for Python syntax coloring

I am implementing the method I learned here for putting Python code in Latex. Everything works great except that I have problems with comments. Here's the code from the link I mentioned: ...
3
votes
1answer
739 views

How to define default 'program listing' title and parameters in Lyx

I'm using LyX software and need to embed python code snippets and the option I found is to put snippet in a file and then use: insert> file> Child Document ----> choose the snippet file ----> set ...
3
votes
2answers
954 views

Macro that inserts arguments into an environment

I'm having a bit of an issue trying to get a piece of code up and running. I'm working on extending python.sty file for embedding python into a LaTex document (adding persistent data and the ability ...
3
votes
1answer
120 views

How to plot barplot horizontally in LaTeX

I want to plot a barplot horizontally. I have tried using the following code, but it prints a vertical plot: \documentclass[varwidth=true, border=2pt]{standalone} \usepackage{pgfplots} ...