Skip to content

Conversation

@cderv
Copy link
Collaborator

@cderv cderv commented Feb 12, 2026

When rendering the same .qmd to PDF multiple times, the .tex output differs between runs. The tcolorbox options in the \Shaded environment preamble appear in a different order each time (e.g. frame hidden, interior hidden, breakable, sharp corners vs boxrule=0pt, sharp corners, breakable, enhanced, frame hidden, interior hidden).

Root Cause

tColorOptions() in src/resources/filters/common/latex.lua uses Lua's pairs() to iterate over the options table. pairs() does not guarantee iteration order, so the emitted option string varies between runs.

Fix

Replace pairs() with spairs() (sorted pairs), which is already available globally from src/resources/filters/common/table.lua. This produces alphabetically sorted options, making the output deterministic.

Fixes #14017

`tColorOptions()` used `pairs()` which iterates Lua table keys in
non-deterministic order, causing `.tex` output to differ between
renders of the same document. Switch to `spairs()` for sorted
iteration so tcolorbox options are always emitted alphabetically.
@posit-snyk-bot
Copy link
Collaborator

posit-snyk-bot commented Feb 12, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@cderv cderv merged commit 319c1f4 into main Feb 12, 2026
51 checks passed
@cderv cderv deleted the fix/issue-14017 branch February 12, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LaTeX Line under \begin{document} created in random order

2 participants