This repository was archived by the owner on Jan 31, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlvdebug-doc.tex
More file actions
128 lines (102 loc) · 5.59 KB
/
lvdebug-doc.tex
File metadata and controls
128 lines (102 loc) · 5.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
\documentclass{article}
\usepackage{graphicx,listings,lmodern,luatextra,booktabs}
\newcommand\pkgversion{see Makefile}
\newcommand*\pgsmall{\fontsize{8.5}{8.7}\selectfont\ttfamily}
\lstset{basicstyle=\pgsmall,
basewidth=0.55em,
columns=fullflexible,
breakautoindent=true,
breaklines=true,
prebreak=,
postbreak=\mbox{$\hookrightarrow$},
}
\begin{document}
\title{The lua-visual-debug package (V\pkgversion)}
\author{Patrick Gundlach}
% \address{patrick@gundla.ch}
\maketitle
\tableofcontents
\section{About}
This package aids debugging your \TeX\ and \LaTeX\ document by drawing rectangles around boxes and rules where glue is inserted. Other items are marked as well: kerns, hyphenation points and penalties.
\section{How to use}
When you load the package \texttt{lua-visual-debug} in your \LuaLaTeX\ document (or use \verb|\input lua-visual-debug.sty| in plain \TeX), \LuaTeX\ will highlight boxes, penalties, glues and kerns in the PDF. This package requires you to process the document with \LuaTeX\ (plain and \LaTeX formats).
\section{A \LaTeX\ example}
\lstinputlisting[language=tex]{sample.tex}
\noindent yields \vspace{5mm}
\noindent \includegraphics[width=\textwidth]{sample-crop.pdf}
\section{A plain \TeX\ example}
\lstinputlisting[language=tex]{sample-plain.tex}
\noindent yields \vspace{5mm}
\noindent \includegraphics{sample-plain-crop.pdf}
\section{How to interpret the markers} % (fold)
\label{sec:how_to_interpret_the_markers}
\noindent\includegraphics[width=.9\textwidth]{lvdebugdetail1-num}
\begin{enumerate}
\item A vertical glue. Beginning and end are marked with a small tick. At the mark 1, two vertical glues are connected.
\item A horizontal glue. Blue dashed lines represent stretched glues, magenta lines represent shrunk glues, gray at their natural width.
\item A negative kern. Positive kerns are yellow.
\item A possible hyphenation point.
\item Horizontal and vertical boxes are drawn with a border.
\item Penalties are marked with a square. A penalty of 10,000 is marked with a blank square, a penalty less than 10,000 is filled with a gray square (that will improve in the future, currently it is grayness of penalty / 10000).
\end{enumerate}
A strut box (zero width box) is marked with a red rule:
\noindent\includegraphics[scale=0.8]{strut}
% section how_to_interpret_the_ (end)
\newpage
\section{Configuration}
The \verb|\lvdset| macro modifies the markers described in Section~\ref{sec:how_to_interpret_the_markers}.
It accepts a list of space-separated \texttt{key/val} pairs. Most keys accept nested \texttt{key/val} pairs
enclosed in curly braces. PDF operators (for \texttt{color}, \texttt{negative\_color}, and \texttt{opacity})
must be enclosed in curly braces, e.g., \verb|\lvdset{glyph={color={1 0 0 RG}}}|.
\medskip
\noindent
\begin{tabular}{@{}lllp{6cm}@{}}
\toprule
\textbf{Key} & \textbf{Sub-key} & \textbf{Default} & \textbf{Description} \\
\midrule
\texttt{hlist} & \texttt{show} & \texttt{true} & Whether to mark hlists \\
& \texttt{color} & \texttt{0.5 G} & PDF stroking color operator \\
& \texttt{width} & \texttt{0.1} & Line width in bp units \\
\midrule
\texttt{vlist} & \texttt{show} & \texttt{true} & Whether to mark vlists \\
& \texttt{color} & \texttt{0.1 G} & PDF stroking color operator \\
& \texttt{width} & \texttt{0.1} & Line width in bp units \\
\midrule
\texttt{rule} & \texttt{show} & \texttt{true} & Whether to mark rules \\
& \texttt{color} & \texttt{1 0 0 RG} & PDF stroking color operator \\
& \texttt{width} & \texttt{0.4} & Line width in bp units \\
\midrule
\texttt{disc} & \texttt{show} & \texttt{true} & Whether to mark discretionaries \\
& \texttt{color} & \texttt{0 0 1 RG} & PDF stroking color operator \\
& \texttt{width} & \texttt{0.3} & Line width in bp units \\
\midrule
\texttt{glue} & \texttt{show} & \texttt{true} & Whether to mark glue \\
\midrule
\texttt{kern} & \texttt{show} & \texttt{true} & Whether to mark kerns \\
& \texttt{color} & \texttt{1 1 0 rg} & PDF color for positive kerns (stroke and fill) \\
& \texttt{negative\_color} & \texttt{1 0 0 rg} & PDF color for negative kerns (stroke and fill) \\
& \texttt{width} & \texttt{1} & Line width in bp units \\
\midrule
\texttt{penalty} & \texttt{show} & \texttt{true} & Whether to mark penalties \\
\midrule
\texttt{glyph} & \texttt{show} & \texttt{false} & Whether to mark glyphs \\
& \texttt{color} & \texttt{1 0 0 RG} & PDF stroking color operator \\
& \texttt{width} & \texttt{0.1} & Line width in bp units \\
& \texttt{baseline} & \texttt{true} & Whether to mark the baseline \\
\midrule
\texttt{onlyglyphs} & — & — & Shortcut to disable all markers except glyphs \\
\midrule
\texttt{opacity} & — & (empty) & PDF graphics state operator for transparency \\
\bottomrule
\end{tabular}
\medskip
\noindent
\textit{Notes:}
\begin{itemize}
\item The \texttt{kern} key uses both stroke and fill colors, unlike other keys which only use stroking color.
\item The \texttt{onlyglyphs} key is a boolean flag (no value needed) that sets all \texttt{show} keys to \texttt{false} except \texttt{glyph/show}, which is set to \texttt{true}.
\item The \texttt{opacity} key applies to all node types. For fine-tuned opacity control per node type, the \texttt{color} keys can be (ab)used to include graphics state operators.
\end{itemize}
\section{Copying}
Copyright 2012–2023 Patrick Gundlach (patrick@gundla.ch) and other authors (see Git for information), licensed under the MIT license. See the Lua file for details.
\end{document}