Section 01 · Getting Started
Installation & Engine Compatibility
annotex consists of two core runtime files — annotex.sty (LaTeX3/TikZ) and annotex.lua (pure-Lua vector-PDF text parser) — and requires LaTeX2e (2021-06-01 or newer) along with standard TeX Live / MiKTeX packages (expl3, xparse, l3keys2e, iftex, graphicx, xcolor, tikz). No external binaries and no --shell-escape flag are needed.
| TeX Engine | Core Features (Grid, Sidebar, Book Boxes, \atxnote, \atxmemo, Auto-Fit, Lightbulb) | Native Vector Text Search (\atxquote, \atxhl) |
|---|---|---|
| LuaLaTeX Recommended | Full support | Full native support (pure Lua, zero --shell-escape) |
| pdfLaTeX | Full support | Graceful fallback with informative warning |
| XeLaTeX | Full support | Graceful fallback with informative warning |
# Option A: Place annotex.sty and annotex.lua directly beside your .tex document # Option B: Install into your personal TEXMFHOME tree: mkdir -p "$(kpsewhich -var-value=TEXMFHOME)/tex/latex/annotex" cp annotex.sty annotex.lua "$(kpsewhich -var-value=TEXMFHOME)/tex/latex/annotex/" mktexlsr # only needed if your TeX distribution caches TEXMFHOME
Section 02 · Quick Start
Recommended Three-Step Workflow
Inspect the Coordinate Grid
Load your PDF with default grid=true and compile once with lualatex. Read exact decimal (row, col) positions directly off the translucent blueprint grid.
Annotate Page by Page
Open an annotexpage environment for each page you want to annotate, mixing \atxnote, \atxquote, and \atxmemo freely. Unannotated pages pass through automatically.
Export the Clean Final PDF
Switch grid=false inside \annotexsetup to hide both the coordinate overlay and dashed box frames (when box-frame=auto) for a clean archival edition.
\documentclass{article} % For Chinese notes, use \documentclass[UTF8]{ctexart} \usepackage{annotex} \annotexsetup{ sidebar = true, % extended side margin (default) sidebar-side = right, % right | left | outer | inner sidebar-width = 0.25, % 1/4 of original page width (or e.g. 5cm) grid = true, % set false for final reading copy opacity = 0.35, % global positioning-layer opacity note-font-size = 8pt, % global base note font size auto-fit = true, % shrink font on overflow (zero extra pages) numbering = continuous, % continuous | per-page | none } \begin{document} \annotexload{examples/sample-source.pdf} \begin{annotexpage}{1} \atxmemo{Page summary pinned automatically to the top of the sidebar.} \atxquote{introduce a hierarchical refinement workflow}{Vector sentence highlight!} \atxnote{45.5}{53.0}{Coordinate note at row 45.5, col 53.0. Supports multiple paragraphs, equations $E=mc^2$, and figures: \includegraphics[width=\linewidth]{examples/sample-chart.pdf}} \end{annotexpage} \end{document}
Section 03 · Page Layout
Extended Sidebar vs. In-Page Book-Symmetric Boxes
All global layout options are declared after \usepackage{annotex} (before \begin{document}) via \annotexsetup and \annotexarea, and can be overridden on any single page inside annotexpage. Every source PDF page keeps its exact original physical dimensions — even across mixed portrait and landscape PDFs.
Applies options globally when called in the preamble (or before \annotexload). When called inside \begin{annotexpage}...\end{annotexpage}, changes apply strictly to that page and revert automatically upon closing the environment.
Declares a rectangular annotation container directly inside the original PDF's coordinate space (top-to-bottom rows 0–100, left-to-right cols 0–100). Call multiple times to register several boxes per page (overflowing notes spill automatically into subsequent boxes). Clear active boxes with \annotexclearareas.
-
book=true(aliasestwoside,mirror-even): Automatically mirrors everypages=allbox horizontally across the page centerline on even (verso) pages:[col1, col2] → [cols − col2, cols − col1]. -
page-parity-offset=1: Shifts odd/even parity detection when a PDF begins with an unnumbered cover page. -
sidebar-side=outer|inner: In sidebar mode, dynamically switches the extended margin between right/left on odd and even pages.
Zoom
Zoom
Section 04 · Coordinate Overlay
Semi-Transparent Coordinate Grid & Global Opacity
Enabled by default (grid=true, opacity=0.35), annotex draws a crisp non-obscuring positioning overlay over every source PDF page: dense edge tick marks & row/column numbers, major horizontal and vertical lines every N units (default 10), periodic inline R/C coordinates along the grid lines, optional dotted minor lines, and dashed frames around user-defined annotation boxes when sidebar=false.
\annotexsetup{ grid = true, opacity = 0.35, % global transparency for grid & box frames rows = 100, % vertical coordinate scale (0 top .. 100 bottom) cols = 100, % horizontal coordinate scale (0 left .. 100 right) grid-step = 10, % major horizontal & vertical line interval minor-grid = true, % dotted sub-grid every minor-step (default 5) row-label-step = 2, % dense row labels along vertical edge col-label-step = 5, % column labels along horizontal edge grid-edges = all, % tl (default) | tr | bl | br | all inline-labels = true, % periodic R10 / C20 labels on grid lines grid-color = teal!75!black, }
Zoom
Zoom
Section 05 · Document Flow
Loading PDFs & Per-Page Scope Control
Loads the target PDF after \begin{document}. Use pages=all (default) to emit every page, pages=annotated to emit only pages that have an annotexpage block, or explicit page ranges like pages=1-3,6,9-. Remaining unrendered pages are flushed automatically at \end{document} (or manually via \annotexflush). Use \annotexpagecount to read total pages and \annotexdebugtext{p} to dump Lua-extracted text of page p to your .log.
Targets physical page <page> (1-based) of the loaded PDF. Any earlier pages skipped since the last block are emitted automatically in order. By default, every global option is inherited. Passing inherit=false (alias reset-layout) resets all visual/layout/grid/sidebar/box settings to clean package defaults so you can build that page's layout from scratch with local \annotexsetup / \annotexarea — while note numbering STILL continues seamlessly from the previous page by default!
Section 06 · Core Commands
Three Note Modes & Two Highlighting Helpers
All five commands below are used inside an annotexpage environment. All public command names use the annotex or atx prefix and are verified conflict-free against mainstream TeX Live packages (amsmath, tikz, hyperref, tcolorbox, todonotes, marginnote, pdfpages, ctex).
Places a translucent numbered badge at decimal coordinates (row, col) on the PDF body (default: multiply-blended yellow circle with black non-bold digit, never obscuring text underneath) and starts typesetting <note content> aligned to <row> inside the sidebar or annotation box. Full LaTeX body support: blank-line multi-paragraph text, equations, itemized lists, tables, and \includegraphics[width=\linewidth]{...}.
Searches the vector PDF page natively in pure Lua (LuaLaTeX, zero --shell-escape), highlights every spanned line of <sentence> in translucent multiply-blended yellow, places the badge neatly beside the match (default marker-pos=end with gentle offset so text is never covered), and aligns <note content> to the quote's vertical row (quote-align=first|center|last). Handles line wraps, two-column reading order, ligatures (fi/fl), end-of-line hyphenation, TeX escapes (\%, \&, \$, \_), and CJK UTF-8.
Typesets a pure margin/box note with NO marker drawn on the PDF body, while still participating in numbering (or showing the unnumbered icon). Default placement=follow pins the memo to the top of the container if it is the first note on the page, or attaches it directly beneath the preceding note. Also accepts placement=top, placement=bottom, or an explicit vertical row={...}.
\atxhl highlights, underlines, or strikes through a vector-PDF sentence without creating a margin note. \atxrect draws a translucent rounded rectangular callout frame over coordinates (r1, c1)–(r2, c2) — ideal for highlighting equations, charts, or regions of scanned raster PDFs.
Zoom
Zoom
Section 07 · Visual Identity
Numbering Modes, Translucent Markers & Lightbulb Icon
Configure numbering globally or per page: continuous (default), per-page (restarts at page-start-number on every page), or none (unnumbered). Whenever numbering=none (or numbered=false on an individual note), Type 1 and Type 2 in-page markers automatically render as a pure glowing vector yellow lightbulb icon — with NO yellow enclosing circle — keeping the page visually light and expressive.
Numbered markers on the PDF body default to marker-opacity=0.48, marker-text-opacity=0.68, and marker-blend=true (PDF multiply blend mode), so even if a marker overlaps text or equations, every glyph beneath stays completely readable.
% Custom pure-LaTeX marker command (avoid nested \tikz inside marker-cmd) \newcommand{\mybadge}[1]{\colorbox{blue!15}{\color{blue!75!black}\sffamily\scriptsize\bfseries #1}} \begin{annotexpage}[sidebar-side=left, sidebar-width=4.6cm]{1} \atxnote{22}{45}{Default translucent yellow circle (Note 1).} \atxnote[marker-shape=rounded, marker-bold=true, marker-underline=true, marker-color=red!80!black, marker-highlight=orange!25]{45}{38}{Custom crimson badge (Note 2).} \atxnote[marker-cmd=\mybadge]{63}{52}{Custom macro badge (Note 3).} \end{annotexpage} % Unnumbered page: pure glowing yellow vector lightbulb (no enclosing circle) \begin{annotexpage}[numbering=none]{2} \atxquote{three benchmark problems}{Pure yellow lightbulb beside quote!} \end{annotexpage} % Local visual reset via inherit=false — numbering still continues at 4! \begin{annotexpage}[inherit=false]{3} \annotexsetup{note-style=leftbar} \atxnote{30}{42}{Continues seamlessly from Note 3 as Note 4!} \end{annotexpage}
Zoom
Zoom
Zoom
Section 08 · Overflow & Containment
Auto-Floating, Box Containment, Auto-Fit Font & Forced Clipping
Every sidebar and in-page annotation box enforces exact column width (\hsize) with zero paragraph indentation and a hard geometric TikZ \clip boundary — notes can never bleed outside their designated box. When multiple notes compete for vertical space, two anti-collision float solvers keep them neatly separated: cascade (default row-aligned downward float with bottom rebound) or balanced (least-squares Pool Adjacent Violators Algorithm).
Default (auto-fit=true): If total notes exceed container height at your base note-font-size (default 8pt), annotex iteratively scales the font size down (until min-note-font-size=4.2pt) and re-typesets at full column width so everything fits on the same page.
Forced Fixed Font (auto-fit=false or overflow=clip): Keeps your exact global or per-page note-font-size untouched; any excess beyond the bottom box edge is cleanly clipped (with a log warning).
Zoom
Zoom
Section 09 · Complete API Reference
Complete Key-Value Option Reference
Every key below can be passed as a package option, in \annotexsetup, in \annotexload, or in \begin{annotexpage}[...]{p}. Visual marker, highlight, and note keys may also be overridden on individual \atxnote, \atxquote, and \atxmemo calls.
| Key (Aliases) | Default | Description |
|---|---|---|
| 1. Sidebar & Page Layout | ||
sidebar | true | Generate an extended margin panel beside the PDF (true/false). |
sidebar-side (side) | right | Side placement: right, left, outer (book outside), or inner. |
sidebar-width | 0.25 | Fraction of original PDF width (e.g. 0.25, 1/3) or explicit TeX length (e.g. 5cm). |
sidebar-bg | none | Sidebar background tint (e.g. gray!5, yellow!6, or none). |
sidebar-rule / -color / -width | true / black!25 / 0.5pt | Vertical divider rule between original PDF and sidebar, with color & thickness. |
sidebar-pad-x / -top / -bottom | 8pt / 12pt | Inner horizontal and top/bottom padding inside the sidebar. |
| 2. In-Page Annotation Boxes & Book Symmetry (sidebar=false) | ||
book (twoside, mirror-even) | false | Mirror all-page annotation boxes horizontally across the center on even pages. |
page-parity-offset | 0 | Integer offset added to page number before evaluating odd/even parity. |
note-area / add-note-area | — | Replace or append an annotation box {r1,c1,r2,c2} inline inside \annotexsetup. |
odd-note-area / even-note-area | — | Append an odd-page-only or even-page-only annotation box {r1,c1,r2,c2}. |
box-frame | auto | Show dashed annotation box border: auto (follows grid), true, or false. |
box-color / box-opacity / box-fill | orange!75!black / opacity / orange!15 | Border stroke color, opacity (defaults to global opacity), and subtle interior tint (or none). |
box-line-width / box-style / box-pad / box-label | 0.8pt / dashed / 4pt / true | Border line width, TikZ stroke style, inner note padding, and corner label tag toggle. |
| 3. Global Opacity & Coordinate Positioning Grid | ||
opacity | 0.35 | Global default transparency for the positioning grid overlay and box frames. |
grid | true | Toggle the semi-transparent coordinate positioning grid (default on). |
rows / cols | 100 / 100 | Coordinate resolution (top-to-bottom rows and left-to-right columns). |
row-line-step / col-line-step (grid-step) | 10 / 10 | Spacing of major horizontal and vertical positioning lines. |
minor-grid / minor-step | false / 5 | Enable dotted minor sub-grid lines and interval (also minor-row-step / minor-col-step). |
row-tick-step / col-tick-step (tick-step) | 1 / 1 | Edge tick mark density along the borders. |
row-label-step / col-label-step (label-step) | 2 / 5 | Edge numeric row/column label spacing. |
grid-edges | tl | Which page borders display ticks & labels: tl, all, tr, bl, br. |
inline-labels / inline-step | true / 20 | Periodic coordinate labels stamped along major grid lines (also inline-row-step / inline-col-step). |
inline-row-prefix / inline-col-prefix | R / C | Prefix before inline grid labels (set empty for bare numbers). |
grid-color / grid-opacity / grid-line-width / grid-font | blue!55!cyan!80!black / 0.35pt | Grid color, optional dedicated opacity override, line thickness, and label font. |
| 4. Numbering System & Unnumbered Lightbulb Icon | ||
numbering | continuous | continuous (global across pages), per-page (page), or none (off — switches in-page markers to yellow lightbulb). |
start-number / page-start-number | 1 / 1 | Initial global counter (or starting number for current annotexpage) and per-page reset value. |
number-format | arabic | Counter display format: arabic, alph, Alph, roman, or Roman. |
number-prefix / number-suffix | empty | Optional strings prepended/appended to numbers (e.g. prefix S gives S1, S2). |
local-numbering | false | When true inside annotexpage, restores global counter on exit so next page continues uninterrupted. |
bulb-color / bulb-highlight | yellow / orange | Glass fill and radiating light-ray accent of the pure vector lightbulb icon. |
bulb-border / bulb-opacity | black!75 / 0.72 | Outline color and translucent body opacity of the lightbulb over PDF content. |
bulb-scale / bulb-rays / bulb-cmd | 1.0 / true / empty | Size multiplier, glowing ray toggle, or custom zero-argument replacement macro. |
| 5. Body Marker Styling | ||
marker-shape | circle | Badge shape: circle (default), square, rounded, plain, or diamond. |
marker-color / marker-highlight (marker-fill) | black / yellow!90!orange!80 | Digit text color and highlight fill color (use none for no fill). |
marker-opacity / marker-text-opacity | 0.48 / 0.68 | Translucent fill opacity and digit/border opacity on the PDF body so text stays legible. |
marker-blend | true | Apply PDF multiply blend mode to body marker fill for razor-sharp underlying ink. |
marker-border / marker-border-width | black!70 / 0.45pt | Badge outline color (none disables outline) and line thickness. |
marker-bold / marker-underline | false / false | Toggle boldface (default non-bold) and underline on the marker digit. |
marker-font / marker-size / marker-scale | \sffamily\scriptsize / 9.5pt / 1.0 | Marker typography, minimum diameter, and overall scaling factor. |
marker-style / marker-cmd | empty | Append raw TikZ node styles, or supply a custom 1-arg LaTeX macro \cmd{#1}. |
| 6. Vector-PDF Text Highlighting (\atxquote & \atxhl) | ||
highlight-color / highlight-opacity | yellow / 0.45 | Sentence highlight color and transparency. |
highlight-blend / highlight-style | true / box | Multiply blend toggle and highlight rendering mode: box, underline, or strike. |
highlight-radius / -pad-x / -pad-y | 1.2pt / 0.8pt / 0.8pt | Corner rounding radius and horizontal/vertical padding around matched glyphs. |
marker-pos / marker-offset-x / -offset-y | end / 3.5pt / 3.5pt | Marker anchor beside highlight (end, start, top-end, top-start, right, left) and fine offsets. |
quote-align | first | Margin note vertical anchor for multi-line quotes: first, center, or last line. |
ignore-case / occurrence | false / 1 | Case-insensitive matching and occurrence selector (1, 2, ..., or all). |
| 7. Note Typography, Auto-Fit, Floating & Connectors | ||
note-font-size (note-size) | 8pt | Global or per-page base font size for margin/box notes. |
min-note-font-size / note-line-spread | 4.2pt / 1.22 | Lower font-size floor when auto-fit=true and leading multiplier. |
auto-fit / overflow | true / autofit | auto-fit=true (overflow=autofit) shrinks font on overflow; auto-fit=false (overflow=clip) keeps forced size and clips at box edge. |
note-font / note-color / note-sep | \normalfont / black / 6pt | Note font family/shape, text color, and minimum vertical spacing between notes. |
note-style / note-accent-color / note-bg | plain / orange!75!black / yellow!10 | Note presentation (plain, leftbar, card), accent stripe/border color, and card tint. |
note-align / note-badge | ragged / auto | Paragraph alignment (ragged/justify) and margin badge style (auto/same/bulb/bullet/none). |
float-mode / note-order | cascade / position | Collision solver: cascade (row-aligned downward float + rebound) or balanced (PAVA); order by anchor position or source. |
connector / -color / -opacity / -width / -style | false / black!45 / 0.55 / 0.45pt / densely dotted | Draw leader line connecting each body marker to its margin/box note. |
| 8. Loading & Per-Note Control | ||
pages / auto-flush | all / true | Pages to output (all, annotated, or range like 1-3,5,8-) and automatic flush at \end{document}. |
inherit (reset-layout) | true | Inside annotexpage, false resets visual/layout settings to defaults while keeping numbering continuous. |
label / numbered | — | Per-note custom label string override or single-note numbering toggle (true/false). |
placement (position) / row / area | follow / — / 0 (auto) | Per-note \atxmemo placement (follow/top/bottom), explicit vertical row, or explicit in-page box index 1, 2, … |
Section 10 · Best Practices
Troubleshooting, Tips & License
1. Diagnosing tricky fonts in \atxquote: Run \annotexdebugtext{p} to print the exact searchable text Lua extracted from page p into your .log file.
2. Scanned (image-only) PDFs: Raster scans have no vector text stream — pair the coordinate grid with \atxnote and \atxrect.
3. Custom marker-cmd macros: Use pure LaTeX/xcolor commands (like \colorbox) rather than nesting a second \tikz inside a TikZ node; for raw TikZ styling, pass options directly to marker-style={...}.
4. Chinese notes & Chinese PDFs: Use \documentclass[UTF8]{ctexart} and compile with lualatex for seamless CJK typography and UTF-8 vector sentence highlighting.
Author & Maintainer: Xufeng Zhang (张旭峰) · [email protected]
License: Distributed under the LaTeX Project Public License (LPPL) version 1.3c or later. See the accompanying LICENSE file.