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

learn more… | top users | synonyms

35
votes
3answers
962 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 ...
30
votes
7answers
2k 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
545 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} ...
17
votes
1answer
534 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} ...
16
votes
4answers
677 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. ...
16
votes
2answers
8k 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, ...
14
votes
3answers
904 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 ...
14
votes
1answer
801 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
1k 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 ...
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
1answer
2k 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 ...
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
346 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
2answers
771 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
0answers
135 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
230 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
1answer
327 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
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
200 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
116 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
286 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
370 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
198 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
382 views

Python code in LaTeX not running

I managed, thankfully with your help, to run python code in LaTeX. Unfortunately the code below is not running (simple commands like print "hi" are running). Could anybody tell me, what the problem ...
4
votes
2answers
793 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
1k 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
142 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
245 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
88 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
122 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
201 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 ...
3
votes
1answer
104 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 ...
3
votes
1answer
234 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
261 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
2answers
874 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
98 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} ...
3
votes
1answer
487 views

PythonTeX rendering problem

I tried the PythonTeX package, and the output it produced contained question marks instead of running python code, what should i do ??
3
votes
1answer
392 views

Use Parameter defined in PythonTex in Latex to open File

I have a Python code which detects my files. Now I will open it in Latex. But it seems not possible to give the detected names to Latex I have tried this: \begin{pycode} l = [f for f in ...
3
votes
1answer
243 views

Command line SVG2TikZ

(Apologies if this is too far from topic, but I thought it might be of interest to some here) I am writing a makefile to take a bunch of SVGs that I have drawn and turn them into TikZ pictures via ...
3
votes
1answer
476 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 ...
3
votes
0answers
2k 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
0answers
38 views

Matching cmyk colors in plot to LaTeX [duplicate]

I'm plotting something using the Python package 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 ...
3
votes
0answers
141 views

minted creating garbage output on PDF file [closed]

Good Day, I'm using texlive 2013 which I updated today 20JULY13. When I attempt to compile my LaTeX file using only the most basic minted statements \begin{minted}{c} Test \end{minted} results in ...
3
votes
0answers
248 views

What is a working python code snippet for escaping a string, so that it can be included in a tex file? [closed]

I'm using python to populate a tex template with arbitrary strings - and I would like to escape the strings so they're interpreted and displayed properly inside the tex file (rather than having them ...
3
votes
0answers
129 views

can (pdf)LaTeX change the font in a figure at compilation time [duplicate]

Possible Duplicate: Set fonts in matplotlib graphs equal to tex document I create figures using Python / Matplotlib and saved them in .pdf and .eps format. I'm writing a (long and complex) ...
2
votes
3answers
2k views

Error when using the python package

I am very new to LaTeX. I need to run python package in LaTeX but I can't. I use MiKTeX 2.9 under Windows 7 but the programs gives me this error: Latex error: ! I can't find file ...