CTAN Comprehensive TeX Archive Network

Verzeichnis macros/latex/contrib/pygmentex

README.md

Pygmen

A Python-based package for typesetting code listings using Pygments.

Pygments is a generic syntax highlighter for general use in all kinds of software such as forum systems, wikis or other applications that need to prettify source code.

Requirements: You need to have Python and Pygments installed. For instructions, please refer to the Pygments home page.

The Pygmen Difference: Efficiency through Batching

Unlike other packages that call Pygments for each code snippet (a slow process), Pygmen collects all snippets and processes them in a single batch. This can lead to a significant reduction in compilation time for documents with many listings.

Quick Start

  1. Installation: Place the pygmentex.sty file in a directory where can find it. Ensure the pygmentex.py script is executable and located in a directory in your PATH.
  1. Use it in your document:
  2.  \documentclass{article}
     \usepackage{pygmentex} % Uses the 'default' style by default
    
\begin{document}
% Highlight a code snippet
\begin{pygmented}[lang=c]
#include <stdio.h>
int main(void)
{
   int a, b, c;
   printf("Enter two numbers to add: ");
   scanf("%d%d", &a, &b);
   c = a + b;
   printf("Sum of entered numbers = %d\n", c);
   return 0;
}
\end{pygmented}
% Highlight in line
In this program, \pyginline[lang=c]|int| is a type and
\pyginline[lang=c]|"Enter two numbers to add: "| is a literal
string.
% Highlight an external file
\inputpygmented[lang=java, style=monokai]{Factorial.java}
\end{document}
```
  1. Compile the document with (first run): Snippets are collected into a .snippets file.
  2. Run the Python Script: Process the snippets with pygmentex.py to generate a .pygmented file.
  3.  pygmentex.py your_document.snippets
     
  4. Compile the document with (second run): The final document is produced using the pre-formatted output.
Note: Shell escape (--shell-escape) is not required. The processing is a separate, explicit step. However, if shell escape is enabled, the pygmentex.py script may be executed automatically.

For full documentation and examples, see the compiled manual.

License

This project is licensed under the Project Public License (LPPL), version v1.3c or later.

Herunterladen des vollständigen Inhalts dieses Pakets in einem Zip-Archiv (755.8k).

pygmentex – Use Pygments to format code listings in documents

Pygmen is a Python-based package that can be used for typesetting code listings in a document using Pygments.

Pygments is a generic syntax highlighter for general use in all kinds of software such as forum systems, wikis or other applications that need to prettify source code.

Paketpygmentex
Version0.12.1 2026-03-19
LizenzenThe Project Public License 1.3
Copyright2014–2026 José Romildo Malaquias
BetreuerJosé Romildo Malaquias
Enthalten inTeX Live als pygmentex
MiKTeX als pygmentex
ThemenListings
Syntax-Highlighting
...
Gästebuch Seiten-Struktur Impressum Autor kontaktieren