What is the STY file format?
A .sty file is a plain-text file that contains style definitions used for formatting LaTeX documents. Commands are introduced with a backslash (` \ ), while comments are marked with a percentage sign (%). .sty files are loaded by .tex or .ltx documents via the \usepackage{name}` command to apply their formatting to the given document.
.sty files can be reused across any number of documents. Style definitions can also be set directly in a document's preamble; packaging them in .sty form makes them shareable. A modern .sty opens with a \ProvidesPackage declaration that stamps the package name, date, and version.
LaTeX is very popular in scientific and academic publishing, where .sty files are commonly used to standardize document layouts and formatting. Packages are distributed through CTAN and bundled in TeX distributions such as TeX Live and MiKTeX. Many .sty files are generated from a .dtx source using a .ins script; the .cls format serves the same role for overall document structure.
Security & safety
RISK: MEDIUMA .sty is executable TeX code that runs when LaTeX compiles your document. TeX can read and (with \write18/shell-escape enabled) even run external commands, so a malicious style file could in principle write files or execute programs during compilation. Most distributions ship with shell-escape restricted by default, which limits this. Treat .sty files from unknown sources like any downloaded code: prefer packages from CTAN/your distribution, read an unfamiliar one before compiling with it, and don't enable unrestricted shell-escape for files you don't trust. Viewing a .sty in a text editor is harmless.
Format details
in a nutshellPrograms that open STY files
Technical details
deep spec| File type | Plain-text TeX macro source file |
| MIME type | text/x-tex (also accepted: application/x-tex, text/plain) |
| Character encoding | ASCII or UTF-8; UTF-8 is the default input encoding since the LaTeX 2018 release |
| Load command | \usepackage{name} in the document preamble; options passed as \usepackage[opt1,opt2]{name} |
| Package self-declaration | \ProvidesPackage{name}[YYYY/MM/DD vX.Y description] stamps identity and version in the compilation log |
| Option handling | \DeclareOption{key}{code} defines accepted options; \ProcessOptions executes those chosen by the user |
| Dependency declaration | \RequirePackage{name}[min-date] declares dependencies, equivalent to \usepackage but safe inside package code |
| Binary signature | None - plain text; modern files conventionally start with % comment lines followed by \NeedsTeXFormat{LaTeX2e} |
| Typical file size | 1 KB - 200 KB depending on package complexity |
| Companion format | .cls document class - same TeX macro language but loaded with \documentclass and governs overall document structure |
| Source format | Many .sty files are extracted from a .dtx documented source file using a .ins install driver script |
| Distribution | Published on CTAN; bundled in TeX Live (cross-platform) and MiKTeX (Windows) |
| Platform support | Any operating system with a TeX distribution installed: Windows, macOS, Linux, BSD |
| Syntax markers | Backslash (\) introduces every command; percent (%) starts a comment extending to end of line |
| Modern programming layer | Packages may use the LaTeX3 / expl3 layer (\ExplSyntaxOn...\ExplSyntaxOff) for structured macro programming |
| Released | 1985 (LaTeX); package mechanism formalised in LaTeX2e, 1994 |
| Latest version | N/A (no version number on the format itself; tracked per package and by LaTeX2e/LaTeX3 releases) |
| Open standard | Yes · royalty-free |
| Specification | www.latex-project.org |
STY conversions
Community Q&A
asked by usersNo questions yet - be the first to ask about STY files.