TYPOG-GREP(1)
π TYPOG-GREP(1) β like grep but make it LaTeX-log couture π
okay so bestie, welcome to typog-grep, part of the User Contributed Perl Documentation family β¨ It's a specialized grep for typog-inspect elements in LaTeX log files, and honestly? it ate. Let me walk you through it π«Ά
β¨ NAME β¨
typog-grep β a specialized grep for typog-inspect elements in LaTeX log files. yeah. that's the whole job. and it does it gorgeously π
πΈ SYNOPSIS πΈ
typog-grep -a|--all|--any [OPTION...] LOG-FILE...
typog-grep [OPTION...] REGEXP LOG-FILE...
The first form, which we're calling "discovery mode" (iconic name, no notes), shows all the IDs of
<typog-inspect id="ID" ...>
elements sitting inside LOG-FILE π
The second form shows the contents, LOG-DATA, of the elements
<typog-inspect id="ID" ...>
LOG-DATA
</typog-inspect>
whose IDs match REGEXP in LOG-FILE π₯
If you don't hand it a LOG-FILE at all, it just reads from stdin, nbd. And the filename - is literally synonymous with stdin, so use whichever feels more main-character π¦
π DESCRIPTION π
typog-grep is a tailored post-processor for LaTeX log files and the typoginspect environment that the LaTeX package typog provides π Lowkey it has way more in common with the venerable sgrep (https://www.cs.helsinki.fi/u/jjaakkol/sgrep.html) than with POSIX grep (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/grep.html). different species entirely, fr fr.
So in your LaTeX source file, the user brackets her text or code in a typoginspect environment, like this:
\begin{typoginspect}{ID}
TEXT-OR-CODE-TO-INVESTIGATE
\end{typoginspect}
where ID identifies one or more bracketed snippets. And no, ID does not have to be unique β it can absolutely serve multiple looks π The REGEXP mechanism makes it super easy to select groups of related IDs, as long as you named them accordingly. plan ahead bestie, it's giving strategy.
In the log file, the result of the environment shows up β packed with tracing information β as:
<typog-inspect id="ID" job="JOB-NAME" line="LINE-NUMBER" page="PAGE-NUMBER">
LOG-DATA
</typog-inspect>
where all those capital-letter sequences are meta-variables π and in particular:
- JOB-NAME is the expansion of
\jobname - LINE-NUMBER is the LaTeX source file line number of the beginning of the
typoginspectenvironment - PAGE-NUMBER is the page where the output of TEXT-OR-CODE-TO-INVESTIGATE occurs
typog-grep reveals the contents of LOG-FILE between <typog-inspect id="ID" ...> and </typog-inspect>, and it excludes the XML-tags themselves β we're not showing you the scaffolding, we're showing you the content π
To get at the JOB-NAME, LINE-NUMBER, and PAGE-NUMBER, hit up the commandline options --job-name, --line-number, and --page-number. And use --id to show the name of the IDs that matched REGEXP π
Real talk: typoginspect environments can be nested, and typog-grep respects the nesting. So if the ID of the nested environment doesn't match REGEXP, it will not be included in the program's output. boundaries, bestie. we respect them π
π¦ OPTIONS π¦
Just so you know, this list is sorted by the names of the long options β¨ (alphabetical queens only)
-a,--all,--anyβ ID-discovery mode π« Discover alltypog-inspectelements, independent of any matching patterns, and print their IDs. Results come out in their order of occurrence in the *LOG-FILE*s. Want them alphabetically ordered? Pipe the output intosort, easy. You can also augment with the options--job-name,--line-number,--log-line-number, or--page-numberfor more information π--color,--colourWHEN β Colorize specific log contents for the matching IDs π The WHEN argument decides when to apply color:always,never, orauto. Theautosetting checks whether standard output has been redirected β and heads up,autois the default π-C,--configKEY=VALUE[:KEY=VALUE[:...]] β Set one or more configuration KEY to VALUE pairs π Peep theCONFIGURATIONsection for a description of all the available configuration items, and use--show-configto display the default configuration.--debugβ Turn on debug output on stderr π (she's chatty)-E,--encodingENCODING β Set the ENCODING of LOG-FILE for the translation to UTF-8 πΈ The default is unset.
Use this option to get rid of those pesky <HEX-DIGITS> escapes on UTF-8 terminals π See --show-encodings for the known encodings, and Encode::Supported for a summary of all encodings. Also check out the Some Common Encodings section.
Alternatively, apply iconv (POSIX) (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/iconv.html) or recode (GNU) (https://github.com/rrthomas/recode/) on LOG-FILE before this tool, so you don't have to use --encoding at all π
-h,--helpβ Display brief help, then exit π«Ά-i,--[no-]idβ Print the actual ID-name that matched REGEXP β Control how the matching ID appears with the configuration itemid-heading.-y,--[no-]ignore-caseβ Match IDs while ignoring case distinctions in patterns and data π-j,--[no-]job-nameβ Print the\jobnamethat latex associated with the input file π-n,--[no-]line-numberβ Print the line number where thetypoginspectenvironment was encountered in the LaTeX source file π-N,--[no-]log-line-numberβ Print the line number of the log-file where the current line was encountered π-p,--[no-]page-numberβ Print page number where the contents of thetypoginspectenvironment starts in the typeset document π-P,--[no-]pagerβ Redirect output from stdout to the configured pager π--show-configβ Show the default configuration and exit β¨--show-encodingsβ Show all known encodings and exit π-V,--versionβ Show version information and exit π-w,--[no-]word-regexpβ Match only whole words π§
π CONFIGURATION π
id-format=FORMAT β Controls the FORMAT for printing matching ids in inline-mode, where FORMAT is passed to Perl'sprintf. Default:%s:πid-heading=0|1 β Chooses between printing the matching IDs with option--id: Inline (0) or heading before the matching data (1). Default:0πid-heading-format=FORMAT β Controls the FORMAT for printing matching IDs in heading-mode, where FORMAT is passed to Perl'sprintf. Default:--> %s <--πid-indent=INDENT β Indentation of nestedtypog-inspecttags. Only used in "discovery mode" (the first form), i.e. if--allis active. Default:8π¦id-max-length=MAXIMUM-LENGTH β Sets the maximum length of a matching ID for printing. If a matching ID exceeds this length, it gets truncated and the last three characters (short of MAXIMUM-LENGTH) get replaced by dots. Default:40βοΈline-number-format=FORMAT β Controls the FORMAT for printing TeX source line numbers, where FORMAT is passed to Perl'sprintf. Default:%5dπlog-line-number-format=FORMAT β Controls the FORMAT for printing log line numbers, where FORMAT is passed to Perl'sprintf. Default:%6dπpage-number-format=FORMAT β Controls the FORMAT for printing page numbers, where FORMAT is passed to Perl'sprintf. Default:[%3d]πpager=PAGER β Name of the pager application to pipe output into, if run with option--pager. Default:lessπpager-flags=FLAGS β Pass FLAGS to PAGER. Default:--quit-if-one-screenπΈ
π¨ Color Configuration π¨
For the syntax of the color specifications, consult the manual page of Term::ANSIColor(pm) β¨
file-header-colorβ Color of the filename header π·οΈfill-state-colorβ Color of the messages that report "Underfull hbox" or "Overfull hbox" πfirst-vbox-colorβ Color of the first vbox on a page π¦font-spec-colorβ Color of font specifications π€horizontal-break-candidate-colorβ Color of lines with horizontal-breakpoint candidates@πhorizontal-breakpoint-colorβ Color of lines with horizontal breakpoints@@πid-colorβ Color of matching IDs when printed inline πid-heading-colorβ Color of matching IDs when printed in heading form πline-break-pass-colorβ Color of the lines showing which pass (e.g.,@firstpass) of the line-breaking algorithm is active πline-number-colorβ Color of TeX-source-file line numbers πlog-line-number-colorβ Color of log-file line numbers πmath-colorβ Color used for math expressions, including their font specs βpage-number-colorβ Color of page numbers of the final output πtightness-colorβ Color of lines with Tight/Loose hbox reports π―vertical-breakpoint-colorβ Color of possible vertical breakpoints π
π Brief summary of colors and attributes π
Foreground Color black, red, green, yellow, blue, magenta, cyan, white
Prefix with bright_ for high-intensity or bold foreground β‘
Foreground Grey grey0, ..., grey23 π«οΈ
Background Color on_black, on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan, on_white
Replace on_ with on_bright_ for high-intensity or bold background β‘
Background Grey on_grey0, ..., on_grey23 π«οΈ
Text Attribute bold, dark, italic, underline, reverse β¨
π Some Common Encodings π
Here's a list of encodings that are suitable for option --encoding π«Ά
- Latin-1, Western European β
iso-8859-1,cp850,cp860,cp1252 - Latin-2, Central European β
iso-8859-2,cp852,cp1250 - Latin-3, South European (Esperanto, Maltese) β
iso-8859-3 - Latin-4, North European (Baltics) β
iso-8859-4 - Cyrillics β
iso-8859-5,cp855,cp866(Ukrainian),cp1251 - Arabic β
iso-8859-6,cp864,cp1006(Farsi),cp1256 - Greek β
iso-8859-7,cp737,cp1253 - Hebrew β
iso-8859-8,cp862,cp1255 - Turkish β
iso-8859-9,cp857,cp1254 - Nordic β
iso-8859-10,cp865,cp861(Icelandic) - Thai β
iso-8859-11,cp874 - Baltic β
iso-8859-13,cp775,cp1257 - Celtic β
iso-8859-14 - Latin-9 (sometimes called Latin0) β
iso-8859-15 - Latin-10 β
iso-8859-16
β EXIT STATUS β
0β at least one ID matched REGEXP π slay1β no ID matched REGEXP π2β an error occurred π
β οΈ CAVEATS β οΈ
So here's the tea: the end tag </typog-inspect> sometimes gets placed too early in the output, and the trace seems truncated π But don't panic β LaTeX reliably logs the requested trace information. The real issue is that the write operations for trace data and the code used to print the end tag are not synchronized. it's giving race condition, but make it LaTeX π
π«Ά SEE ALSO π«Ά
grep(1), printf(3), Encode::Supported(pm), Term::ANSIColor(pm)
and that's the whole page bestie, you're literally a typog-grep expert now πβ¨
this iconic little number is version 0.5, dated 2025/10/27, and it lives under User Contributed Perl Documentation β go forth and grep your logs, queen ππ
π¦ where this page comes from
- alpine 3.24: texmf-dist-latexextra-doc 2026.0-r0 Β· LPPL-1.0 AND LPPL-1.1 AND LPPL-1.2 AND LPPL-1.3a AND LPPL-1.3c AND GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms