If you are trying to use the new LaTeX tagging features or fix transparency issues in LyX, you’ve probably run into the error:
! LaTeX DocumentMetadata Error: \DocumentMetadata should be used only before \documentclass
This happens because the LaTeX Preamble in LyX settings is injected after the \documentclass and internal font setups.
The Fix in LyX 2.4: You don't need to edit layout files or export to TeX manually. LyX 2.4 added a specific field for this:
- Go to Document > Settings > PDF Properties.
- Go to the Document Metadata tab/field.
- Paste your keys directly into the box without the command itself. For example:`testphase={phase-III,math},pdfstandard=