Comments (5)
No, this can't be done with a filter. A filter can only play with the pandoc AST; it can't adjust the output of texmath functions.
from texmath.
No, there isn't. In principle, it could be added, but this would require:
- an extra parameter on the texmath typst reader to determine whether symbol names should be used
- a new pandoc extension that toggles this
On balance I don't think it's worth the effort and extra complexity.
from texmath.
Thanks for your response!
I would like to expand on my initial request to provide more context.
Since math rendering in HTML supports so many flags, I thought it would be trivial to include a --unicode
flag for math that would also be available for Typst.
I do find it a bit odd that even ASCII characters like +
, -
and =
get converted to Typst symbol names. Writing equations with words is like writing Chinese with pinying. It is possible but not expressive. You might appreciate the Chinese poem "Lion-Eating Poet" to know what I mean.
My understanding is that Typst named symbols are just shortcuts to the underlying Unicode characters. I had the chance to look at the texmath
source code. Indeed, it seems that under the hood all math symbols get first converted to Unicode and then to Typst symbol names. I changed the offending function from
-- src/Text/TeXMath/Writers/Typst.hs#L58
writeExp (ESymbol _t s) =
maybe (esc s) id $ M.lookup s typstSymbolMap
to
writeExp (ESymbol _t s) = esc s
Then, I recompiled pandoc with the patched dependency to obtain the desired effect. It works pretty well except for \setdiff
which maps to \
and should be escaped to \\
. Given that I have no experience with Haskell, it took me much longer to figure out how to recompile pandoc with the patched dependency then to patch the function itself. Also thanks to the well-organized and documented source code, it was easy to locate the issue.
If my understanding that Typst uses Unicode is correct, then converting symbols to Unicode is much less complex and error prone. Typst symbols are more likely to change than the Unicode characters, so Unicode would be more robust.
However, if changes in this direction add unnecessary complexity and, especially, requires too much effort I agree that it's not worth the investment. Although, it would be a missed opportunity.
from texmath.
I do find it a bit odd that even ASCII characters like +, - and = get converted to Typst symbol names.
Yes, that's definitely odd, and I can change that in the default behavior. (Avoiding symbol names when the code point is in the ASCII range.)
The change is certainly possible, but it's not trivial. We'd need some mechanism in pandoc to communicate the option to the typst writer in texmath. I would prefer to avoid a new command line option. And I would prefer to avoid any new complexity; that's where bugs come from. Producing typst that resembles examples from the typst documentation seems like a good goal, and that's what we aim at.
from texmath.
I agree that Typst documentation tends to favour the use of named symbols, even though it natively supports UTF-8 characters and named symbols are nothing more than sugar for their UTF-8 representation. I believe that this is to cater to users who might find it difficult to input non-ASCII characters, are coming from LaTex and/or might have problems installing UTF-8 fonts.
The only mention to UTF-8 input in Typst documentation is in this section of the documentation which is one the things that sold Typst to me.
You can use all Typst functions within math mode and insert any content. If you want them to work normally, with code mode in the argument list, you can prefix their call with a #. Nobody can stop you from using rectangles or emoji as your variables anymore:
$ sum^10_(🥸=1) #rect(width: 4mm, height: 2mm)/🥸 = 🧠 maltese $If you'd like to enter your mathematical symbols directly as Unicode, that is possible, too!
In any case, Typst documentation is probably outside of the scope of this issue. If you have to make a choice, I agree that you have to pick one option consistently.
However, is there anyway I could write a Pandoc filter to avoid calling the conversion to named symbols in the function below?
-- src/Text/TeXMath/Writers/Typst.hs#L58
writeExp (ESymbol _t s) =
maybe (esc s) id $ M.lookup s typstSymbolMap
I would be happy to live with a Pandoc filter. Certainly better than a patched Pandoc. I'm just not sure how to go about it. Any advice would be super-helpful.
from texmath.
Related Issues (20)
- latex/markdown to typst overline conversion
- `U_{\frac{1}{n}}` gets converted to `U_1 / n` for LaTeX to typst.
- \tilde{x} from LaTeX to typst should get converted to accent(x,tilde.op) instead
- $\underbrace{x}_{y}$ from LaTeX to typst
- mathml vector - typeset error HOT 1
- texmath converts $s_n$ to $space_n$ from LaTeX to Typst HOT 1
- MathML <mo> created for each adjacent Rel symbol HOT 5
- texmath-0.12.8 testsuite failure in Nightly HOT 3
- Feature request: color
- Installing `texmath` binary as dependency in Nix project HOT 2
- how to run server HOT 2
- Wrong equation conversion from docx HOT 4
- pandoc cannot convert latex formula containing "*{20}{l}" HOT 1
- Recognise `\allowbreak` in TeX input
- texmath converts $\ddot{q}$ to $q^(̈)$ from LaTeX to Typst HOT 3
- Do not use extra lr in typst writer HOT 2
- Minus for subtraction and minus for negative numbers not differentiated in default HTML math output HOT 5
- Pandoc cannot recognize some uppercase Greek letters and lowercase omicron HOT 8
- Math not correctly converted to typst: `\mathbf` should be bold and upright but is only bold
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from texmath.