Skip to content

Queries

github-actions[bot] edited this page Nov 25, 2026 · 1 revision

SaTeX: Static Analysis for (La)TeX and Friends

Queries

satex query NAME -f FILE runs a query and prints its records. satex query --list names them all. Every query takes --filter EXPR (e.g. 'tag=macro and arity>0') and --format json/csv. Input, configuration, output and exit codes work as for every command, see the command line page. The examples analyze samples/paper.tex.

  • calls: which control sequences each macro's body invokes (since 0.1.0)
  • catcodes: explicit \catcode assignments the document makes (since 0.1.0)
  • definitions: every macro, environment and register the document or its packages define (since 0.1.0)
  • dependencies: files, packages and classes read, and what loaded each (since 0.1.0)
  • dependency-graph: the dependency graph between files and packages as records (since 0.1.0)
  • diagnostics: what satex noticed while interpreting, apart from lint rules (since 0.1.0)
  • distribution: the detected TeX installation, version and searched trees (since 0.1.0)
  • expansions: how often each macro was expanded during the run (since 0.1.0)
  • exports: the names installed packages define, each with the package or library to load (since 0.2.5)
  • files: every file read, in the order it was opened (since 0.1.0)
  • gaps: constructs the run could not interpret, grouped by cause (since 0.1.0)
  • letters: where a punctuation character becomes a letter or stops being one: what names are typeable where (since 0.2.6)
  • occurrences: package banners, passed options and other one-off events (since 0.1.0)
  • options: the keys an environment or command's optional argument accepts (since 0.1.0)
  • pgfkeys: pgfkeys defined at the end of the run and what each does (since 0.1.0)
  • plugins: what each plugin chose for this run, and why (since 0.1.0)
  • previews: arrow tips and patterns the run declared, drawn by TeX (since 0.2.0)
  • produces: where a given text can come from, expanded or not (since 0.1.0)
  • project: document class, engine and build settings detected or assumed (since 0.1.0)
  • recursion: macros that call themselves, directly or through others (since 0.1.0)
  • side-effects: definitions and assignments a macro makes when called (since 0.1.0)
  • tagging: PDF tagging: whether it is on, the standard, language, title and each package's status (since 0.2.5)
  • trace: every step: macro expansions, primitives run, changes made (only with trace: true, or use satex trace) (since 0.1.0)
  • type-plugins: the editor's type plugins: the types each triggers on and its features (since 0.2.0)
  • typeset: the text the document typesets, one row per paragraph (since 0.2.0)

calls

The call graph: which control sequences a macro's replacement text invokes.

$ satex query calls -f samples/paper.tex --filter 'name=\maketitle'
name        callee                  
\maketitle  \@ifnextchar            
\maketitle  \let                    
\maketitle  \@footnotetext          
\maketitle  \@footnotemark          
\maketitle  \H@@footnotetext        
… 6 more lines omitted

catcodes

Explicit category code assignments (\catcode) the document makes. doc/src/wiki/queries/demo.tex makes ! active:

$ satex query catcodes -f doc/src/wiki/queries/demo.tex
code  kind    key  detail     
13    Active  !    was Other  

definitions

Every name the document or its packages define. origin is document for files in the main file's directory tree, library otherwise. package names the package or class.

$ satex query definitions -f samples/paper.tex --filter 'tag=macro and arity>0'
tag    name      paramet…  comment   arguments    body      file                  
macro  \__sys_…  #1                               \str_if…  expl3-code.tex        @ expl3-code.tex:1539:17
macro  \sys_gs…  #1                               \tex_se…  expl3-code.tex        @ expl3-code.tex:1531:34
macro  \reserv…  #1.sty\…                         \def \r…  latex.ltx             @ latex.ltx:18742:20
macro  \reserv…  #10#2#{                          \expand…  latex.ltx             @ latex.ltx:1277:3
macro  \reserv…  #1\@nil                          \@for \…  latex.ltx             @ latex.ltx:18611:3
… 2591 more lines omitted

dependencies

The files, packages and classes the document reads, and what loaded each. Lua modules loaded by \directlua chunks appear with kind lua. texlive names each file's TeX Live package (see configuration).

$ satex query dependencies -f samples/paper.tex --filter 'kind=package'
kind     status          name            by              file                
package  read            amsmath                         paper.tex           @ paper.tex:4:1
package  read            amstext         amsmath         amsmath.sty         @ amsmath.sty:126:1
package  read            amsgen          amstext         amstext.sty         @ amstext.sty:27:1
package  read            amsbsy          amsmath         amsmath.sty         @ amsmath.sty:127:1
package  already-loaded  amsgen          amsbsy          amsbsy.sty          @ amsbsy.sty:27:1
… 49 more lines omitted

dependency-graph

The dependency graph as records. satex dependencies renders it as DOT or JSON (see the command line).

$ satex query dependency-graph -f samples/paper.tex --filter 'file=paper.tex'
tag                  name                                                          file       
macro-call           \documentclass                                                paper.tex  @ paper.tex:1:1
variable-definition  \pkgcls@targetdate                                            paper.tex  @ paper.tex:1:1
use                  @                                                             paper.tex  @ paper.tex:1:1
use                  11pt                                                          paper.tex  @ paper.tex:1:1
macro-call           \value                                                        paper.tex  @ paper.tex:0:0
… 530 more lines omitted

diagnostics

Everything SaTeX noticed while interpreting the document: widened conditionals, extra \else, and the rest of the internal diagnostics distinct from the lint rules. satex lint and the editor show the findings that matter.

$ satex query diagnostics -f samples/paper.tex
severity    code                count  message                         file            
assumption  page-one-arm        1      an undecided choice while a p…  latex.ltx       @ latex.ltx:9350:12
assumption  forced-page-breaks  1      the page may fill here, and p…  paper.tex       @ paper.tex:82:15
assumption  page-one-arm        1      an undecided choice while a p…  latex.ltx       @ latex.ltx:20715:3
assumption  page-one-arm        1      an undecided choice while a p…  latex.ltx       @ latex.ltx:20717:7
assumption  clock-assumed       1      the document is assumed to be…  expl3-code.tex  @ expl3-code.tex:8203:38

distribution

The detected TeX installation: provider, version, and the texmf trees searched.

$ satex query distribution -f samples/paper.tex
kind        name                                                 count  message   root                                  
                                                                        TeX Liv…                                        
texmf-tree                                                                        ~/texmf                   
texmf-tree                                                                        ~/.texliveYYYY/texmf-var  
texmf-tree                                                                        /usr/local/texlive/texmf-local        
texmf-tree                                                                        /usr/local/texlive/YYYY/texmf-config  
… 5384 more lines omitted

expansions

Every macro call, with how many times it was expanded.

$ satex query expansions -f samples/paper.tex --filter 'name=\newcommand'
name         count  package         file                
\newcommand  1      article         article.cls         @ article.cls:48:1
\newcommand  1      article         article.cls         @ article.cls:203:3
\newcommand  1      article         article.cls         @ article.cls:268:1
\newcommand  1      article         article.cls         @ article.cls:302:1
\newcommand  1      article         article.cls         @ article.cls:306:1
… 163 more lines omitted

files

Every file read while analyzing the document, in the order it was opened.

$ satex query files -f samples/paper.tex
id   kind     file                                      
0    input    paper.tex                                 
1    input    latex.ltx                                 
2    input    texsys.cfg                                
3    input    texsys.aux                                
4    input    expl3.ltx                                 
… 307 more lines omitted

gaps

Lists the places the run could not interpret, grouped by cause. Widened recursion and undecided conditionals are not gaps: both stay sound. satex --stats and gaps.log use the same list.

$ satex query gaps -f doc/src/wiki/challenges/06-unknown.tex
severity     code                    count  message                        file            
unsupported  unbalanced-conditional  1      end of 06-unknown.tex occurr…  06-unknown.tex  @ 06-unknown.tex:0:0

letters

Where a punctuation character becomes a letter (catcode 11) or stops being one, per file of the project, at the user's line that caused it (\makeatletter, \ExplSyntaxOn). Line 0 holds the letters a file opened with (@ in a package). Replayed up to a place, the records give the characters a command's name may hold there. Completion uses them to end the name typed (after \sum_ in a body none is typed) and to offer only names typeable there, and the playground's editor colors command names by them.

occurrences

Package and class identification banners, passed options, and other one-off events.

$ satex query occurrences -f samples/paper.tex --filter 'kind=identification'
kind            key                   detail                  file                  
identification  article               2025/01/22 v1.4n Stan…  article.cls           @ article.cls:45:1
identification  size11.clo            2025/01/22 v1.4n Stan…  size11.clo            @ size11.clo:44:1
identification  amsmath               2025/07/09 v2.17z AMS…  amsmath.sty           @ amsmath.sty:29:1
identification  amstext               2024/11/17 v2.01 AMS …  amstext.sty           @ amstext.sty:26:1
identification  amsgen                1999/11/30 v2.0 gener…  amsgen.sty            @ amsgen.sty:26:1
… 38 more lines omitted

options

--for NAME lists the keys an environment's or command's optional argument accepts. SaTeX follows what the command's code calls until it reaches a key-setting call (keyval, xkeyval, pgfkeys, l3keys, or a package's own copy such as enumitem's) and lists the keys of the family it used. An optional argument that takes no keys (enumerate's label template) is reported as positional.

This needs call arguments recorded (record_arguments). query options and --for in a request turn that on.

mybanner in samples/mypackage.sty takes an optional argument but reads it directly ([plain], no keys), so it comes back positional:

$ satex query options --for mybanner -f samples/mypackage.sty
kind        name       detail                                                                                  
positional  \mybanner  takes an optional argument (\mybanner[plain]) not read through a recognized key family  

pgfkeys

The pgfkeys keys defined at the end of the run and what each does (initial, code, code args, is family, is choice, is if). --prefix PATH narrows to one path, e.g. /tikz/pingu.

$ satex query pgfkeys -f samples/keys.tex
kind       key       value     default                                       detail    file      
is family  /demo     \edef \…                                                          keys.tex  @ keys.tex:5:1
style      /demo/c…  \pgfkey…  red                                                     keys.tex  @ keys.tex:5:1
is if      /demo/d…  \pgfkey…  true                                                    keys.tex  @ keys.tex:5:1
initial    /demo/f…  /demo                                                             keys.tex  @ keys.tex:5:1
code args  /demo/l…  \def \d…                                                          keys.tex  @ keys.tex:5:1
… 1932 more lines omitted

plugins

The provider, platform, engine, output target, and build system plugins chose for this run, and why. The values and what they are detected from are in configuration.

$ satex query plugins -f samples/paper.tex
kind              name                                                                               detail             
provider          texlive (TeX 3.141592653 (TeX Live 2026))                                          detected           
platform          linux                                                                              this machine       
engine            pdflatex (pdftex primitives)                                                       build configurat…  
kernel            latex2e                                                                            default            
output            pdf                                                                                build configurat…  
… 4 more lines omitted

previews

The arrow tips and fill patterns the run declared, each drawn by TeX (latex and dvisvgm) as SVG. The names are arrow:SPEC and pattern:NAME. The pictures are kept in previews.json in the cache directory, where completion reads them. doc/src/wiki/queries/demo.tex loads the arrows.meta and patterns libraries:

$ satex query previews -f doc/src/wiki/queries/demo.tex
name                                      
arrow:-.                                  
arrow:-<                                  
arrow:->                                  
arrow:->|                                 
arrow:-Bar                                
… 261 more lines omitted

produces

Where a piece of text can come from, with or without expansion. --text is a literal, case-sensitive substring. kind says how: source (literal in a file. tag comment if commented out), macro body (at the definition), value (a register, counter or length. Dimensions in points), occurrence (a label, section title, …), metadata (\title, \author, \date), or expansion (a call the run expanded).

$ satex query produces -f samples/paper.tex --text 1.5em
kind        tag          name           detail                             file           
source      class                       \vskip 1.5em%                      article.cls    @ article.cls:184:14
source      class                       \vskip 1.5em%                      article.cls    @ article.cls:243:12
source      class                       \vskip 1.5em}                      article.cls    @ article.cls:253:10
source      class                       \itemindent -1.5em%                article.cls    @ article.cls:392:40
source      class                       \advance\leftmargin 1.5em}%        article.cls    @ article.cls:395:45
source      class                       {\list{}{\listparindent 1.5em%     article.cls    @ article.cls:399:40
source      class                       \setlength\@tempdima{1.5em}%       article.cls    @ article.cls:532:26
… 11 more lines omitted

Only the places that stand behind an expansion, for a text the document never writes out:

$ satex query produces -f samples/paper.tex --text Introduction --filter 'kind!=source'
kind        tag      name                                              detail    file       
macro body  macro    \r@sec:intro                                      {1}{1}{…  paper.aux  @ paper.aux:6:11
occurrence  section  Introduction                                      Introdu…  paper.tex  @ paper.tex:33:1
occurrence  write    \@writefiletoccontentslinesectionnumberline1Int…  \@write…  latex.ltx  @ latex.ltx:9552:34
occurrence  write    \newlabelsec:intro11Introductionsection.1         \newlab…  latex.ltx  @ latex.ltx:9552:34

Explain

satex explain NAME… shows what a control sequence means: where it is defined, what it takes, what it does. Without -f it explains against the smallest LaTeX document.

$ satex explain '\itshape'
\itshape @ latex.ltx:12499:13
  tag            macro
  context        outside environments
  effective      \itshape
  takes          0
  uses           0 times, in this run
  by             \def
  does           Switches to italic.
  documentation  The LaTeX2e sources, [source2e](https://ctan.org/pkg/source2e)
  body           \not@math@alphabet \itshape \mathit \fontshape \itdefault \selectfont 
… 2 more lines omitted

project

The document class, engine, and build configuration SaTeX detected or was told to assume (see profiles). The first row's kernel is the LaTeX kernel's release the run read (\fmtversion). The playground's writers use it (\mathcolor from 2022-06).

The rows below list what the project scan found, without what .gitignore excludes. unreachable lists the inputs, packages, classes and bibliographies no root reads. Without -f, each root document is analyzed on its own.

$ satex query project -f samples/paper.tex
kind       name                                                      count  detail    message                           
document   article [2025/01/22 v1.4n Standard LaTeX document class]         LaTeX2e…  engine pdflatex (build configur…  
latexmk    samples/latexmkrc                                                pdf_mod…                                    
documents                                                            3      samples…                                    
inputs                                                               1      samples…                                    
packages                                                             1      samples…                                    
… 1 more line omitted

recursion

Macros that call themselves, directly or through another macro.

doc/src/wiki/queries/demo.tex defines \countdown, which calls itself:

$ satex query recursion -f doc/src/wiki/queries/demo.tex --filter 'name=\countdown'
kind    name        file      
direct  \countdown  demo.tex  @ demo.tex:8:12

side-effects

Definitions and assignments a macro makes as a side effect of being called, rather than through \def or \newcommand directly at that point.

$ satex query side-effects -f samples/paper.tex --filter 'file=paper.tex'
tag                  name                       detail                       file       
macro-call           \documentclass             while expanding at 731:7     paper.tex  @ paper.tex:1:1
variable-definition  \ifdraft                   while expanding at 3:1       paper.tex  @ paper.tex:3:7
variable-definition  \drafttrue                 while expanding at 3:1       paper.tex  @ paper.tex:3:7
variable-definition  \draftfalse                while expanding at 3:1       paper.tex  @ paper.tex:3:7
macro-call           \usepackage                while expanding at 1:1       paper.tex  @ paper.tex:4:1
… 116 more lines omitted

trace

Every step: which macro expanded, which primitive ran, what changed. Use satex trace. satex query trace is empty unless trace: true is set.

$ satex trace -f samples/paper.tex
index   step         name                        detail    arguments       file           
678     expand       \documentclass                                        paper.tex      @ paper.tex:1:1
8412    open-file    \article                    /usr/lo…                  paper.tex      @ paper.tex:1:1
10261   expand       \par                                                  paper.tex      @ paper.tex:2:1
10268   expand       \newif                                \ifdraft        paper.tex      @ paper.tex:3:1
10272   define       \ifdraft                    iffalse                   paper.tex      @ paper.tex:3:7
… 184 more lines omitted

--lines FROM:TO records only those lines of the main file and what their calls do. --steps FROM:TO only those steps. Either end may be left out (40:, :60). Nothing outside the range is recorded. --from [FILE:]LINE[:COL] starts at a position (FILE is a trailing part of a path, for a subfile, and --to and --lines take it too) and runs to the end. --to [FILE:]LINE[:COL] ends there. --interactive steps through the events one at a time, showing each macro's definition, arguments and inserted tokens: Enter or e steps into a call, o steps over it, l goes to the next line of the main file, s N to line N, c runs on, q quits. Only the document's own files are shown. --include-internal adds packages, classes and the kernel. --format compact prints at most 8 text lines instead: what each top-level call of the main file expands to, and each conditional's outcome. --interactive marks each run of hidden steps in gray, and with --lines, --from or --to ends with the text those lines typeset.

$ satex trace -f samples/paper.tex --lines 10:11
index  step    name         detail                        file       
0      expand  \newcommand                                paper.tex  @ paper.tex:11:1
105    define  \highlight   \long macro:#1->\textbf {#1}  paper.tex  @ paper.tex:11:13

Dev mode: the state at each step

--state (or trace_state: true) gives each step the analysis state it ran in, to track down where a result lost precision. It costs nothing while off. With --format json each record has a state object. With --format csv it is one JSON cell in the state column. A text table leaves it out.

Key What it contains
paths live paths, forks made so far, the peak, and apart: why the waiting paths do not join (progress, stacks, tags), as SATEX_WHY_APART prints it
choices the undecided choices this path took: the command, its place, arm of arms, and joined when the choice splits a joined meaning set
mode the modes the path may be in
conditionals, groups the conditional and group stacks, innermost first. many marks a widened entry
input the input stack, top first: a file and position, a token list and the macro it expands, a \scantokens text
bindings the step's own name and the names ahead, then the paired ones: meaning, the meaning set may a join left (maybe_undefined when one member is undefined), certain, global, and a register's value
paired the names a join kept paired across its arms, and how many arms
catcodes the catcode of each non-alphanumeric character in the file text ahead

A value names its type in the Ty lattice (number, dimen, glue, muglue, quantity, text, any) and what satex knows about its value: exact, an interval [lo, hi], a set, or unknown. Typed unknown text appears as its own names (unknown digits:0..1439). limits.trace_state caps each list. In the playground, dev mode in the settings turns this on: the trace shows the domains of the selected step, the editor menu offers Inspect state here, and the trace exports as JSON or CSV.

exports

The names the installed packages define, read off their text, each with the file to load for it: the package most files use that defines the name itself, or the TikZ library that declares an arrow tip, shape or key. Names with @ or _ are internals and left out. The site build ships this list to the playground, whose bundle holds only a few packages, so its fixes and completion still name booktabs for \toprule.

tagging

PDF tagging as \DocumentMetadata set it up, read from the run with the kernel's own \GetDocumentProperties: whether tagging is on and under which engine, the PDF standards claimed (UA-2, A-4F), the language (and, under set, the one the preamble wrote, before LaTeX guesses one), the title the XMP gets, and the PDF version. running is the tagging code's own answer at \begin{document} (\tag_if_active:TF), which \tagpdfsetup can turn against the declaration. modules are the tagging code's files the run read, marked the marked-content sequences it wrote by tag (pdfTeX). Then each loaded package and class with its status in TeX Live's latex-tagging-status.ltx, which satex runs as TeX: unlisted where the list has no entry. Without \DocumentMetadata only these statuses: what turning tagging on would meet. An installation without the list gives none. The tagging lints read the same facts.

type-plugins

The editor's type plugins this run would offer: each plugin, its category, the types it triggers on and its features. See type plugins for what each does.

$ satex query type-plugins -f samples/paper.tex
category     name             types                                       about                                         
widget       color            color name                                  swatches, colors defined at the position, c…  
widget       environment      environment name                            change one environment to another, both end…  
widget       table            environment the run met                     a grid dialog for each tabular, booktabs an…  
widget       image            graphic file                                a crop, rotate and size dialog for each fig…  
widget       float            environment the run met                     a float's placement: what each letter lets …  
… 22 more lines omitted

typeset

The text satex computes for the typeset document, one row per paragraph, then the named assumptions it rests on. {a|b} is a choice between the arms of an undecided conditional. ⟦x⟧ is text set in a box: it reaches the page only if the box is used. ⟨?⟩ is a character the run could not know. │ is a table's |, ― an \hline or other \hrule, ▬ a \rule bar. Rules of no width (struts) are left out. The challenges compare it with what pdflatex sets.

$ satex query typeset -f doc/src/wiki/challenges/04-typesetting.tex
3:25  paragraph  ⟦f⟧wide, {empty page|page started}
6:15  page  page 1
assumption  page-one-arm
assumption  clock-assumed

In JSON each row also says where its characters came from. sites gives where each was set. origins gives where a character was read, when that is elsewhere. Its source names who wrote that text: document, class, package or kernel. def and def_line name the macro whose replacement text held it. generated marks text made by expanding a primitive there, such as \number\year in \today or the digits of \thepage. math marks where the math mode changes: inline, display, math when either may hold, and an empty mode where math ends. The playground's origins and math layers draw these.

Several definitions

If the preamble meaning differs from the one at the end of the run, both are shown. --all lists every definition with its place.

Contexts

A name can mean different things in different places: \item outside a list is the kernel's error, inside enumerate it starts an item. Each definition records the environments open where it was made, and explain shows one record per distinct meaning. context says where it applies ("outside environments", "in enumerate, itemize", …).

A name without its own redefinitions can still behave differently by context. error is the error a real use raised there, or, without a real use, what running the command in that context raises.

Signatures

signature spells what a command reads, one letter per argument, in the notation of LaTeX's \NewDocumentCommand (usrguide):

key reads
m a mandatory argument: a braced group or one token
o an optional […] argument, absent when no [ follows
O{default} an optional […] argument with the default it takes when left out
s an optional star *
t⟨c⟩ an optional token ⟨c⟩
r⟨a⟩⟨b⟩, R⟨a⟩⟨b⟩{default} a mandatory argument delimited by ⟨a⟩…⟨b⟩
d⟨a⟩⟨b⟩, D⟨a⟩⟨b⟩{default} an optional argument delimited by ⟨a⟩…⟨b⟩
u⟨tokens⟩ everything up to ⟨tokens⟩
v verbatim text
e{…}, E{…}{…} embellishments such as ^ and _
+, !, >{…} before a letter: may contain \par, no spaces before it, a processor applied to it
… the probe could not decide the rest

effective writes a call: \section*?[1]{2} is som (optional star, optional argument, mandatory argument). [default] shows a default. takes is the least and most arguments a call reads.

SaTeX finds a signature by running the command on probe input and watching what it reads (SEMANTICS § 13, "What a command takes").

Locations

--at WHERE asks for the meaning at one place instead of the default preamble/document view (a suffix on the name would be ambiguous, since @ is a letter in LaTeX's internal names):

  • --at preamble: the meaning right before \begin{document}.
  • --at document: the meaning at the end of the run.
  • --at 302: the meaning at line 302 of the main file.
  • --at somefile.tex:302: the meaning at line 302 of somefile.tex, a file the run read.
  • --at after:enumitem: the meaning right after the enumitem package finished contributing what it defines.

In a request, an explain entry takes the same place as "at".

$ satex explain '\itshape' --at preamble
\itshape @ latex.ltx:1416:0
  tag            macro
  when           preamble
  context        outside environments
  effective      \itshape
  takes          0
  package        kernel
  does           Switches to italic.
… 4 more lines omitted

Slice

satex slice NAME… keeps what a name, environment or label depends on (--forward: what depends on it) and prints it as a compilable LaTeX document. --list or --format json/csv/markdown prints the records instead.

The criterion is a name, --at [FILE:]LINE:COL[-LINE[:COL]] (a range, to the end of the last line without a column), or --where EXPR over the occurrences/definitions records, e.g. --where 'kind=begin-environment and key=figure' for every figure.

$ satex slice -f samples/paper.tex '\ifdraft'
\begin{filecontents*}[overwrite]{mypackage.sty}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mypackage}[2024/01/01 v1.0 Sample package for satex]

\RequirePackage{xcolor}

… 58 more lines omitted
$ satex slice -f samples/paper.tex --where 'kind=begin-environment and key=figure'
\begin{filecontents*}[overwrite]{mypackage.sty}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mypackage}[2024/01/01 v1.0 Sample package for satex]

\RequirePackage{xcolor}

… 89 more lines omitted

--out DIR writes the slice as a standalone project: the main file plus the local packages, classes, graphics and bibliographies it needs, paths preserved.

Scratch documents in the playground

Work on this in a scratch document slices some lines into a document of their own, for a faster cycle on one figure, table, equation or paragraph. The playground offers it in three places:

  • the editor's context menu: the selected lines, else the block around the cursor,
  • the bubble beside a selection of a line or more,
  • a right click on the PDF or the Typeset view: the paragraph, figure, table or equation there. The page action slice switches it in the playground's settings.

The scratch document is the root's preamble as written, the body definitions the chosen lines need (from the slice of the run the page already has), and the chosen lines between two marker comments, %\satex@scratch{begin chapter.tex:17-27} and %\satex@scratch{end}. They are a satex directive, so the editor shows them as one and the run reads past them. Without a finished run it falls back to the whole satex slice. It opens as a tab and is the root while it is open, so checks and builds run on the small document. The banner names where it came from, Scratch slice of chapter.tex:17–27, and offers Merge back and Discard.

Merge back shows the region's changes as a diff, then writes the lines between the markers where they came from, as one undo step. Lines added or removed above them meanwhile are followed. When the original lines changed too, the preview shows both sides: Merge writes the scratch version over them, Keep the original drops it. Discard closes the scratch document and writes nothing. Either way the root before comes back.

Merge back: the scratch document's new row as a diff, written as one undo step

Controls

satex controls NAME… shows what a switch, package option or conditional governs. With several names, the for column says which. Without a name it lists the switches and options in effect (--all includes the kernel's and packages'). That analyzes the document's own switches as undecided and is slower. The kernel's and the packages' switches keep their values.

$ satex controls my@draft my@wide -f samples/mypackage.sty
tag    name         for       means                              detail    file           
use    \newcommand  my@draft  \ifmy@draft, the switch `\newif`…  \ifmy@d…  mypackage.sty  @ mypackage.sty:29:3
macro  \mymode      my@draft  \ifmy@draft, the switch `\newif`…  \ifmy@d…  mypackage.sty  @ mypackage.sty:29:15
use    \newcommand  my@draft  \ifmy@draft, the switch `\newif`…  \ifmy@d…  mypackage.sty  @ mypackage.sty:31:3
macro  \mymode      my@draft  \ifmy@draft, the switch `\newif`…  \ifmy@d…  mypackage.sty  @ mypackage.sty:31:15

JSON requests

satex query --request FILE (- for stdin) runs several queries on one analysis and prints one JSON answer per query. The request is a JSON object:

  • file: the document to analyze. Falls back to -f when omitted.
  • config: optional overrides, the same dotted paths --set takes (the keys are on the configuration page): {"limits.memory": "1GiB", "load.packages": false}.
  • queries: an array of query objects, each with a type: any name from the query list above (definitions, pgfkeys, gaps, …, with text/prefix/name/filter as that query takes them), or explain, controls, slice, options, providers, or docs, with their own arguments:
    • explain: names (array), all (bool).
    • controls: names (array), all (bool).
    • slice: names (array), at ("[FILE:]LINE:COL"), forward (bool).
    • options: name.
    • providers: names (array). For each name, the installed package or class that defines it while loading the fewest files.
    • docs: no arguments. What the manuals of the packages and classes the run read say about their commands, one record per command with the directory it was mined from.

Each answer is {"type": …, "records": […]}, or {"type": …, "error": …} for a query that named something wrong. One bad query in the batch does not stop the rest of it.

{
  "file": "samples/mypackage.sty",
  "queries": [
    {"type": "explain", "names": ["\\mybox"]},
    {"type": "controls", "names": ["my@draft"]},
    {"type": "options", "name": "mybanner"}
  ]
}
$ satex query --request doc/src/wiki/request-example.json
[
  {
    "hints": [
      "`\\mybox` has no meaning the run gave it"
    ],
    "records": [],
    "type": "explain"
  },
  {
    "records": [],
    "type": "controls"
  },
  {
    "records": [],
    "type": "options"
  }
]

Clone this wiki locally