STY2DTX(1)
π sty2dtx(1) π
ok bestie, gather round, because this one is sty2dtx, a little Perl script from the User Contributed Perl Documentation section of your man pages, and honestly? it's giving glow-up arc for your LaTeX files. β¨
πΈ NAME πΈ
sty2dtx β no cap, it converts a LaTeX .sty file to a documented .dtx file. that's it. that's the whole job. iconic. π
π¦ VERSION π¦
Version: v2.4 - 2022/10/18 β yeah she's a 2022 girlie but she still slays π
π LINKS π
- CTAN:
https://ctan.org/pkg/sty2dtx - Repository:
https://github.com/MartinScharrer/sty2dtx - Issues:
https://github.com/MartinScharrer/sty2dtx/issues
if something's broken, that last one is literally where you go. do not come for me, come for the issue tracker π«Ά
β COPYRIGHT β
Copyright (c) 2010-2022 Martin Scharrer <martin.scharrer@web.de>
ok so legally speaking, and I am being fr fr here: this program is free software, you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation β either version 3 of the License, or (at your option) any later version.
this program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. that's the dramatic part, keep it. π see the GNU General Public License for more details.
you should have received a copy of the GNU General Public License along with this program. if not β and this is your sign β see https://www.gnu.org/licenses/.
π DESCRIPTION π
So what does she actually DO. She takes your .sty file (a LaTeX package) and turns it into .dtx format (documented LaTeX source) by wrapping those macro definitions in macro and macrocode environments. the macro name? auto-inserted as the argument to the macro environment. no manual labor, we love to see it π
and if there's code lines hanging around outside of macro definitions? those get wrapped in macrocode environments only. empty lines get removed entirely (they were not serving).
ngl, real talk: this script is not meant to be fool proof or 100% accurate. it's a good start for converting undocumented style files into .dtx files β a starting point, not a miracle worker. set your expectations accordingly bestie π
β¨ Basic Usage β¨
perl sty2dtx.pl infile [infile ...] outfile
or
perl sty2dtx.pl < file.sty > file.dtx
π Supported Definitions π
These macro definitions get detected when they're at the start of a line β and yes, they can be prefixed by \global, \long, \protected and/or \outer:
\def \edef \gdef \xdef
\newcommand{\name} \newcommand*{\name}
\newcommand\name \newcommand*\name
\renewcommand{\name} \renewcommand*{\name}
\renewcommand\name \renewcommand*\name
\providecommand{\name} \providecommand*{\name}
\providecommand\name \providecommand*\name
\@namedef{\name} \@namedef\name
And these environment definitions get detected when they're at the start of a line:
\newenvironment{name} \renewenvironemnt{name} \provideenvironment{name}
Now the rules, bestie, because there ARE rules: the macro and environment definition must either end at the same line or end with a "}" on its own on a line. that's the deal. π€
π USAGE π
sty2dtx [<options>] [--<VAR>=<VALUE> ...] [--] [<infile(s)>] [<outfile>]
π Files π
- can be
"-"for STDIN or STDOUT, which is the default if no files are given - multiple input files are merged to one output file
π§ Variables π§
Variables can be defined using
--<VAR>=<VALUE>
or
--<VAR> <VALUE>
and will be used for substitutions in the template file.
Common variables:
author, email, maintainer, year (for copyright),
version, date, description (of package/class),
type (either 'package' default or 'class'),
filebase (automatically set from output or input file name),
π Options π
-hβ Print this help text-Hβ Print extended help-Vβ Print version and copyright-vβ Be verbose-o outputβ Use given file as output-Oβ Overwrite already existing output file(s)-Bβ Use basename of single input file for output file-Iβ Also create.ins(install) file-cβ Only use code section (like v1.0)-rβ Remove existingmacro,macrocode, etc. environments.-Rβ Do not remove existingmacro,macrocode, etc. environments.-i ins-fileβ Create.insfile with given name-t templateβ Use this file as template instead of the default one-T templateβ Use this file as template for the.insfile-e fileβ Export default.dtxtemplate to file and exit-E fileβ Export default.instemplate to file and exit-Dβ Use current date as file date-F fileβ Read more options and variables from file.-Nβ Do not read default config file; must be the first option
π Config files π
A default config file either named sty2dtx.cfg or .sty2dtx.cfg is searched in the current directory, the users home directory and the directory of this script, in this order. The first one found is loaded. If none is found, the texmf tree is searched for a sty2dtx.cfg config file.
As with -F files, the config file should contain one option or variable per line. Lines starting with "%" or "#" are ignored. (those are the comment girlies, let them be π)
β Examples β
Produce file.dtx from file.sty:
sty2dtx.pl < file.sty > file.dtx
or
sty2dtx.pl file.sty file.dtx
or
sty2dtx.pl -B file.sty
Produce file.dtx and file.ins from file.sty:
sty2dtx.pl -I file.sty file.dtx
or
sty2dtx.pl file.sty -i file.sty file.dtx
or
sty2dtx.pl -IB file.sty
Set custom variable values:
sty2dtx.pl --author Me --email me@there.com mypkg.sty mypkg.dtx
Produce DTX file for a class:
sty2dtx.pl --type class mycls.sty mycls.dtx
π AUTHOR π
Martin Scharrer
E-mail: martin.scharrer@web.de
WWW: <http://www.scharrer-online.de>
and that's the whole page bestie!! perl v5.30.0, dated 2022-10-18 β so if you ever see that footer floating around, that's this exact girl. go forth and document your style files, you main character. π¦β¨π
π¦ where this page comes from
- arch rolling: texlive-doc 2026.1-1 Β· GPL
- debian bookworm: texlive-extra-utils 2022.20230122-4
- debian trixie: texlive-extra-utils 2024.20250309-2
- fedora 43: texlive-sty2dtx 11:svn64967-93.fc43 Β· GPL-3.0-or-later
- fedora 43: texlive-sty2dtx 11:svn64967-95.fc43.1 Β· GPL-3.0-or-later
- fedora 44: texlive-sty2dtx 12:svn76924-105.fc44 Β· GPL-3.0-or-later
- fedora 44: texlive-sty2dtx 12:svn76924-111.fc44 Β· GPL-3.0-or-later
- opensuse-leap 16.0: texlive-sty2dtx-doc 2025.221.2.4svn64967-160000.3.1 Β· GPL-2.0-or-later
- ubuntu noble: texlive-extra-utils 2023.20240207-1
- ubuntu questing: texlive-extra-utils 2024.20250309-2
- ubuntu resolute: texlive-extra-utils 2025.20260124-1
- ubuntu stonking: texlive-extra-utils 2026.20260711-2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms