Skip to content

Support more symbols and accents, tests, bug fixes.#1

Open
Danila-Bain wants to merge 7 commits into
NumericalForge:mainfrom
Danila-Bain:main
Open

Support more symbols and accents, tests, bug fixes.#1
Danila-Bain wants to merge 7 commits into
NumericalForge:mainfrom
Danila-Bain:main

Conversation

@Danila-Bain

@Danila-Bain Danila-Bain commented May 17, 2026

Copy link
Copy Markdown

Great project! It worked very well for converting a 15-page document with large amount of formulas and lilaq-powered plots, except for some rough edges, which I tried to solve with this pull request. Figure export is awesome!

Main issues I had are the following.
Fixed:

  • Missing accents (dot, dot.double, etc)
  • Missing symbols
  • Broken figure numeration caused by nesting
  • Missing itemize and enumerate support
  • Theorem environments implemented as figures treated as images. Now we look at figure.kind, and if it is present, we just render the environment with corresponding name.
    Not fixed:
  • Styled math is always wrapped with \boldsymbol. This makes any styling, such as coloring, or show rules, such as show math.equation: math.display, cause affected equations to be wrapped with \boldsymbol, which is just incorrect. I could not fix this, however, because styles field in styled seems to be a black box with no access methods, so checks like if math.bold in elem.styles are not possible.

The details of all changes are readily read from commit comments and diffs.

I did not test many of the implemented functionality, like align or pmatrix environments, and it is possible that I broke table or columns (not tested).

Also I think the project would benefit from splitting the lib.typ into several files (at least separate symbol tables), and following some Typst code styling recommendations, like using more descriptive variable names, like latex-stream for ltx and child-latex for temp, etc.

Other thoughts:

  • After some additional work, this should definitely uploaded to typst universe, the functionality is extremely usefull. Before that, the installation instructions should be added to README.
  • texporter-build should not display, or even render latex by default. It should display it only when it is called like #show: texporter-build.with(display: true) and otherwise only render latex when there is "latex" passed in sys arguments. This would allow to render latex at any time without unnecessary increase of compilation time.
  • Ideally, in generated latex file there should be packages just for the functionality used in the file. This would require mapping from all symbols to their corresponding package, and maintaining the list of required packages during recursive evaluation. Since it may cause significant increase of compilation time, this should be optional and off by default.
  • Ideally, there should be an option that for all (or for chosen) custom math operators, defined with op, declares the corresponding math operators in latex preambule using \DeclareMathOperator, and uses them instead of inline \mathrm or \operatorname. Again, those additional calculations should be off by default, because it is not guaranteed that there would be no name collisions. The common usage for this feature would be redefined \Re and \Im operators.
  • Separately saving figures is just great, I just love it.

// Changelog:
// - Bug fix: rename "mode=figs" -> "mode=figures" to adhere README
// - Support more acent functions, like dot, grave, etc, with error text
when accent is not recognized instead of ignoring it
// - Support `math.limits`
// - Support more math characters
// - Support itemize lists
// - Support `block` and stand-alone `caption`: just render the body.
// - Use eqref when label starts with "eq:"
// - Support figures with custom "kind"s for theorems
// - Support soft-failing for context expressions
// - Fix broken figure numeration with nested calls
// - Minor cosmetic changes: extra new-lines, not trimming text,
increased margin in exported figures
// - Bug fix: escape curly brackets in math mode ("{ }" -> "\{ \}")
// - Remove usage of \\boldsymbol, it was used when not needed in test
documents
Fix identation after it was temporarely turned off.
The identation is no longer increased for "styled" blocks, since it
caused extra identation for no justified reason.
Add src/test/identation.typ
Remove removal of \boldsymbol, so "test/main.typ" is rendered correctly.
Add color-styled equations to "test/main.typ", showing that current
implementation treats all styled math as boldsymbol.

There is an issue that `styled` objects apparently only have `child` and
`styles` fields, where `styles` seems to be unreadable (has no access
methods?).
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.

1 participant