TeX Hover Docs
English | 简体中文
TeX Hover Docs shows documentation for custom LaTeX classes and Beamer themes directly in VS Code. The documentation is stored in the corresponding .cls or .sty file, so it stays next to the definition it describes.
⚠️ This project relies heavily on AI in its development. Although I have not found any problems in my own use so far, please evaluate the risks yourself.
Features
- Hover over a class or theme name to see its description and documented options.
- Hover over an option name to see its description, default, and documented values.
- Hover over a documented value to see what it means.
- Find definition files in the current workspace or, with
kpsewhich, in a TeX installation.
- Read unsaved changes when the definition file is open in VS Code.
For example, with MyClass.cls available to the workspace or TeX, this command can show the class and lang documentation:
\documentclass[lang=en]{MyClass}
Preview


Add documentation to a class
Place one metadata block in MyClass.cls. The marker lines and every JSON line must be LaTeX comments. The name must match the class name used by \documentclass.
% vscode-hover:begin
% {
% "kind": "class",
% "name": "MyClass",
% "description": "A thesis template for Chinese and English documents.",
% "options": {
% "lang": {
% "description": "Sets the document language.",
% "default": "zh",
% "values": {
% "zh": "Simplified Chinese.",
% "en": "English."
% }
% },
% "linenum": {
% "description": "Controls line numbers.",
% "default": "none",
% "values": {
% "none": "Do not show line numbers.",
% "text": "Show line numbers for text only.",
% "all": "Show line numbers for all content."
% }
% }
% }
% }
% vscode-hover:end
An option requires a description. Its default and values fields are optional. Each entry in values maps an option value to its description. Trailing commas are accepted.
Add documentation to a Beamer theme
For \usetheme{MyTheme}, store the metadata in beamerthemeMyTheme.sty and set kind to theme.
% vscode-hover:begin
% {
% "kind": "theme",
% "name": "MyTheme",
% "description": "A presentation theme for research talks.",
% "options": {
% "lang": {
% "description": "Sets the language of theme labels.",
% "default": "zh",
% "values": {
% "zh": "Chinese labels.",
% "en": "English labels."
% }
% }
% }
% }
% vscode-hover:end
File lookup
The extension searches the current workspace first:
\documentclass{MyClass} maps to MyClass.cls.
\usetheme{MyTheme} maps to beamerthemeMyTheme.sty.
If no workspace file is found, the extension runs kpsewhich with the corresponding filename. kpsewhich is optional when all definition files are in the workspace. For files installed in TeX Live or another TeX distribution, make sure kpsewhich is available on the VS Code process PATH.
Extension setting
texHoverDocs.kpsewhichPath sets the executable used for TeX file lookup. It defaults to kpsewhich. Set it when the executable is not on PATH, for example in settings.json on Windows:
{
"texHoverDocs.kpsewhichPath": "D:\\Application\\LaTeX\\texlive\\2025\\bin\\windows\\kpsewhich.exe"
}
Requirements
- Visual Studio Code 1.146.0 or later.
kpsewhich only when definitions are installed outside the workspace.
Build and test
npm install
npm test
npx @vscode/vsce package
To run the extension from source, open this directory in VS Code and press F5 to launch the Extension Development Host. The generated .vsix can be installed with:
code --install-extension tex-hover-docs-0.1.0.vsix
Scope and limitations
The extension provides documentation only; it does not validate options or change how LaTeX processes them. It recognizes direct \documentclass[...]{...} and \usetheme[...]{...} commands, including multiline arguments, while ignoring commands in comments. It does not expand macros or resolve class and theme names generated by other commands. When multiple same-named definitions exist, a workspace file takes precedence over a TeX installation.
License
MIT