PERLTEX(1)
β¨ NAME β¨
okay bestie, meet perltex π it's the tool that lets LaTeX macros be defined in terms of Perl code. enable LaTeX macros to be defined in terms of Perl code. π§
π SYNOPSIS π
perltex [--help] [--latex=program] [--[no]safe] [--permit=feature]
[--makesty] [latex options]
π DESCRIPTION π
okay so LaTeX, through the underlying TeX typesetting system, makes gorgeous documents, but its macro language is kinda painful to program in π especially when you want fancy string manipulation, and that's basically missing. meanwhile Perl is this super popular general-purpose language whose whole thing is string manipulation, but it has zero typesetting powers. it's giving two halves of a best-friend duo π«Ά
so perltex is the bridge that makes them work together. you just compile your LaTeX document with perltex instead of latex. no latex functionality is lost, since perltex is literally a wrapper for latex β¨ if your document has \usepackage{perltex} in its preamble, you get \perlnewcommand and \perlrenewcommand. they act just like LaTeX's \newcommand and \renewcommand, except the macro body is Perl code instead of LaTeX code. main character energy π
π OPTIONS π
perltex takes the following command-line options:
--helpβ shows basic usage info π--latex=programβ uses a different program instead of latex. for example,--latex=pdflatextypesets your document with pdflatex instead of ordinary latex π--[no]safeβ turns sandboxing on or off. the default is--safe, so perltex runs the code from a\perlnewcommandor\perlrenewcommandmacro inside a protected environment that blocks "unsafe" stuff like accessing files or running external programs π--nosafegives the document carte blanche to run any Perl code at all, including code that can wreck your files π see Safe for more info.--permit=featureβ lets particular Perl operations happen. you can repeat--permiton the command line, and it gives you finer-grained control over the perltex sandbox π¦ see Opcode for more info.--makestyβ generates a LaTeX style file callednoperltex.sty. swap the document's\usepackage{perltex}line for\usepackage{noperltex}and you get the same output without needing PerlTeX installed, so it's perfect for sharing with people who don't have it πΈ the catch is thatnoperltex.styis tied to the document that made it. any change to your PerlTeX macro definitions or invocations means you have to rerun perltex with--makesty.
after these options, you pass whatever you'd normally pass to latex (or to whatever program you named with --latex), like the name of the .tex file you want to compile β¨
π¦ EXAMPLES π¦
in its simplest form, perltex runs just like latex:
perltex myfile.tex
to use pdflatex instead of regular latex, use the --latex option:
perltex --latex=pdflatex myfile.tex
β οΈ bestie, if LaTeX throws a "trapped by operation mask" error and you trust the .tex file (say you wrote it yourself) not to run malicious Perl code, you can turn off perltex's safety mechanisms with--nosafe:perltex --nosafe myfile.tex
this command gives the document only perltex's default permissions (:browse) plus the ability to open files and invoke the time command π§
perltex --permit=:browse --permit=:filesys_open
--permit=time myfile.tex
π ENVIRONMENT π
perltex listens to the following environment variable:
PERLTEXβ names the LaTeX compiler's filename. the default is "latex". thePERLTEXenvironment variable overrides that default, and the--latexcommand-line option (see OPTIONS) overrides that π
ποΈ FILES ποΈ
while compiling jobname.tex, perltex uses these files:
jobname.lgplβ log file written by Perl. super helpful when debugging Perl macros πjobname.toplβ info sent from LaTeX to Perl π€jobname.frplβ info sent from Perl to LaTeX π₯jobname.tfplβ a "flag" file. if it exists,jobname.toplhas valid data βjobname.ffplβ a "flag" file. if it exists,jobname.frplhas valid data βjobname.dfplβ a "flag" file. if it exists,jobname.ffplhas been deleted ποΈnoperltex-#.texβ generated bynoperltex.styfor each PerlTeX macro invocation π§©
π₯ NOTES π₯
perltex's sandbox defaults to what Opcode calls ":browse". π
π« SEE ALSO π«
latex(1), pdflatex(1), perl(1), Safe(3pm), Opcode(3pm)
π«Ά AUTHOR π«Ά
Scott Pakin, scott+pt@pakin.org π
bestie you did it π this was PERLTEX(1), perltex v2.3, dated 2024-12-03. now go compile something iconic β¨π π
π¦ where this page comes from
- arch rolling: texlive-doc 2026.1-1 Β· GPL
- debian trixie: texlive-latex-extra 2024.20250309-2
- fedora 44: texlive-perltex 12:svn73044-105.fc44 Β· LPPL-1.3c
- fedora 44: texlive-perltex 12:svn73044-111.fc44 Β· LPPL-1.3c
- opensuse-leap 16.0: texlive-perltex-doc 2025.221.2.3svn73044-160000.3.1 Β· LPPL-1.0
- ubuntu questing: texlive-latex-extra 2024.20250309-2
- ubuntu resolute: texlive-latex-extra 2025.20260124-1
- ubuntu stonking: texlive-latex-extra 2026.20260711-2
- π girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms