converting KaTeX to MathJax - mathjax

Is there currently any way in javascript to convert a KaTeX formular to MathJax, I want to support exporting to Anki which just works with MathJax.
If not, is there a table which shows which commands of KaTeX are not supported in MathJax, I can't seem to find one.
I just need the conversion from KaTeX to MathJax, not the other way around

A workaround might be the new addon for anki that supports katex. I'm not ready to use it yet (there appears to be some bugs with line-breaking. See comments on the link).
https://ankiweb.net/shared/info/1087328706
I have the same use case as you. I write markdown and katex in vscode (with Markdown+Math extension), and export to anki (using ankdown - slightly modified).
I find that sometimes mathjax causes problems - for example with tags.

Related

Is there an alternative to \normalcolor that I can use in MathJax?

\normalcolor does not seem to work on my MathJax code. MathJax doesn't seem to support it.
Is there an alternative command that I can use?

How to do a bold 1 (\mathbbm{1}) in MathJax

I'm looking for blackboard bold numerals in LaTeX displayed with MathJax.
It seems that the \mathbbm command is not (yet) available from MathJax (as said in the documentation).
Is there anyway to have support for the \mathbbm command, e.g., to have nice bold 1 ?
I tried to load an extension, or trick from this question, but nothing works.
Here is an example showing the failure: with makebigmaths.
It seems to be a known and old issue of MathJax, coming from a font limitation.
And no third party extensions seem to solve it.
However, Jupyter notebooks supports it in its Markdown cells.
You can use Unicode characters directly, e.g., 𝟙, or via the non-standard macro \unicode{x1D7D9}.
Both of these can be used in macro definitions as well, cf. http://docs.mathjax.org/en/latest/tex.html#defining-tex-macros.
One can use \Bbb instead of \mathbbm which is mentioned under "Font control" in the current documentation. Judging by the question Obsolete command \Bbb, it is an obsolete TeX command.
I use \Bbb in an align environment using MathJax version 3.2.2 for doxygen.

Macros in MathJaX

I would like to add some macros in my MathJax configuration. Specifically I would like to add:
\arcsin and be displayed as {\rm arcsin}
\arccos and be displayed as {\rm arccos}
\arctan and be displayed as {\rm arctan}
\arccot and be displayed as {\rm arccot}
I have read the MathJaX documentation and although I think that I do the steps right, I end up with either the MathJaX not working properly or not loaded at all. By the way, why are these commands not supported at all? I think they should. Is there a specific reason?
How can I add these macros in my configuration?
MathJax 3 supports all the commands you mentioned (\arcsin, \arccos, \arctan and \arccot) so you don't have to create macros for them. For \arccot, the physics extension must be loaded.

Using latex in internet browsing

Why isn't possible (or feasible) to have latex code written on internet pages: latex being the page's source, like html.
This idea came when I was writing on wikipedia some math article and I realize that the current implementation is quite weak, either in presentation as some things that cannot be written inline.
So, a definitely prettier and simpler approach would be to introduce latex code within the page: the browser would interpret it and, using texlive or equivalent, compile the page with latex generated fonts. This could be inside a HTML, but the generation was using "pure" latex and not some javatex or else.
The latex interpreter could be a plugin of the browser, like Java once was.
This could have profound consequences, like scientific articles be shown on the internet without the need of .pdf or latex based documents be putted on internet in a one click away. The article was code with appropriate packages for internet viewing. The user could at anytime download generate the pdf equivalent of that page.
Any ideas why isn't this feasible /possible?
In general, using LaTeX for web pages is not a good idea - (La)TeX is designed for exact print output, not for a web view of some web page, where the exact display depends on window/screen sizes, user settings, etc.
Also, at least on my computer, TeX combined with a DVI viewer (or PDFTeX with a PDF viewer) is still quite slower than HTML with a web browser to render a similar sized page ... and there is no easy way to have DOM-like scripting for a LaTeX-page, other than regenerating it on each change. You don't want this.
For these parts where this makes sense (mathematic formulas), this actually already works: There are JavaScript interpreters for subsets of LaTeX (i.e. most of math mode), embedded in a normal HTML document. One example is MathJax, which is used on the more math-heavy (i.e. scientific) sites in the Stack Exchange network, like Cryptography Stack Exchange.

how to pretty print source code of common languages in browser html output with javascript?

how to pretty print source code of common languages in browser html output with javascript?
I mean so that there is some indentation and code formatting.
Currently i only got
http://alexgorbatchev.com/SyntaxHighlighter/
for coloring the syntax.
But i would also like some indentation and other formatting.
Example:
user puts in some code.
system formats and highlights code in the browser view.
so-> is there a general code formatter for formatting code?
best in javascript
I am grateful for any help.
Probably SyntaxHighlighter is the most popular. But you have a choice, have a look at 16 Free Javascript Code Syntax Highlighters For Better Programming
If you mean real time syntax highlighter, you can also try JS-CodeEdit:
JS-CodeEdit is a JavaScript editor
that converts your HTML textareas into
a code editor with realtime syntax
highlighting. If added into a form,
the content can be submitted e.g. to
be written to a file. A nice thing is
that you can add as many editors as
you want within a HTML page.
But it support a bit limited list of languages: JavaScript, PHP, Perl, HTML, CSS, XML, SQL (this list is increased with each release).
You might want to check out Giki : http://guyht.github.com/Giki/examples/wiki.html
Its a real time syntax highlighter, very easy to customise.
GitHub Repo: https://github.com/guyht/Giki
Here is a open source command line program, with optional GUI, which can format and highlight approx. 100 programming languages, with configurable colour themes and output as HTML, XHTML, RTF, TeX, LaTeX, terminal escape sequences, SVG and BBCode format. See the complete feature list, examples, screenshots and screencast.
There is also a macOS quick view plugin available, too.
This is not Javascript but you can do the stuff ex. via AJAX.

Resources