Available for beta testing: Math support in notes
In the latest Zotero beta, it's possible to use LaTeX math right within the Zotero note editor.
The note editor supports both inline and block math nodes. You can insert these by right-clicking on the note and selecting Insert → Math. Zotero will automatically insert an inline node if there's already text on the current line and otherwise create a block node. To trigger via the keyboard, surround inline math with
We're using prosemirror-math and KaTeX under the hood to render the nodes within the note editor. If you export the note, you'll get the regular text with $ or $$ delimiters, but it's possible to set up KaTeX or MathJax to render those nodes as math with web fonts or SVG. We'll try to write up a documentation page for how to do that before this leaves beta.
If you are a math-using person, try it out and let us know how it goes!
The note editor supports both inline and block math nodes. You can insert these by right-clicking on the note and selecting Insert → Math. Zotero will automatically insert an inline node if there's already text on the current line and otherwise create a block node. To trigger via the keyboard, surround inline math with
$
(e.g., $2+2$
) or type $$
followed by a space to create a block.We're using prosemirror-math and KaTeX under the hood to render the nodes within the note editor. If you export the note, you'll get the regular text with $ or $$ delimiters, but it's possible to set up KaTeX or MathJax to render those nodes as math with web fonts or SVG. We'll try to write up a documentation page for how to do that before this leaves beta.
If you are a math-using person, try it out and let us know how it goes!
A few remarks:
1) If the inline math becomes too complicated (multiple lines, exponents, ...), the font quickly becomes too small. In that case, the best solution is probably to switch to a block node. I have tried by adding the $ on each side, but this did not work (ParseError). $ should not be allowed in the LaTeX math equation, so it should be possible to interpret the added $ to switch to block equation?
2) Same for splitting the equation in two parts by adding "$$" in the middle of the equation, or "$ some text $".
3) The block adds vertical spacing above and below when there is text next to it. But the vertical spacing is missing between blocks. I would still prefer keeping the vertical spacing between blocks. The "\\" still gives the ability to keep multiple math lines without vertical spacing if that is really needed.
4) I cannot see the current position (blinking vertical bar) when I try to go between two blocks.
5) Going out of a block (right arrow key) located at the end of the note generates a horizontal blinking bar instead of the vertical one. I am not sure if this is the intended behaviour.
6) If I copy paste a text containing LaTeX equations, it stays as text instead of being converted to a LaTeX equation. Should all the text be interpreted? Or have a way to convert text to Math equation when it is already between $.$ or $$.$$?
7) I would like to convert existing text (not yet containing $) to LaTeX. I have tried to highlight and insert Math, but this simply added the inline Math in front instead of converting the highlighted text.
8) I would expect the "Home" and "End" navigation keys to go to the beginning and the end of the currently edited equation.
9) The inline equation is identified by the pointing finger mouse pointer. It is not consistent for the block equation, sometimes with the vertical bar, sometimes with the arrow.
10) The Math nodes do not seem to work in note headings.
11) In the "Fomat Text" menu ("Aa"), the Math block option is displayed as "noteEditor.mathBlock" and going out of the options window.
12) If I create a block math on the first line of an empty standalone note, then exit, then try to edit again, I cannot see the current position selected anymore. It re-appears if I click on the top and bottom lines "$$". I have seen this also in other block math nodes. It usually recovers after moving around or waiting some times. I could not get precise steps to reproduce for all block math nodes.
13) If I try to move the equation (block math), it automatically enters the editing math mode. I probably do not need to see the raw LaTeX if I just want to move an equation.
14) The "Title" of a note displayed in the central pane only shows the raw text and cannot display math equations.
15) Editing a very long inline equation does not wrap text as for the block equation.
16) Trying to edit a math equation from an older version of Zotero deletes the equation completely.
Thanks again for the new feature!
[Tested on Windows 10, Zotero 6.0.14-beta.2+e474ca524]
Two questions:
1) Will math notes support be added to the iOS app too?
2) Will math support also be added to annotations?
May I ask when will the beta be a formal release?
These should be the currently supported functions:
https://katex.org/docs/supported.html
I just added support to Mathpix and Bing equation OCR in the Better Notes plugin. Might that be helpful?
I'm sorry there seems to be no such an 'inline' solution for math in comments currently. The best I can think of is the 'Quick Note' function, provided by the plugin. The first time you click the quick note button on an annotation will parse the markdown format comment and the annotation itself to a new note linked to this annotation. If you click the button again later, the corresponding note will be opened. There you could use the math support in the note.
Not that convenient compared to the possibility to have math in comments natively, but that's what I'm using currently. Just for reference.
https://github.com/windingwind/zotero-better-notes/raw/master/image/README/markdowncomment.png
One more thing I may be able to help with is that I could add a 'render markdown' button on the annotation to preview the math in a popup. Would that be helpful?
Not sure if it was clear, but it would be nice for the math to be rendered in the iOS app as well. I'm guessing that the plugin approach won't help in this case?
The iOS app and web library are still using the old note editor from Zotero 5, but they'll be updated to use the new editor in the future and gain math support at that point.
Yes, exactly what I think. I'll at you once it's ready.
Happen to find a bug with math in notes. If I copy some rich text and paste it into a math block, like an equation from a website, it will break the math.
https://user-images.githubusercontent.com/33902321/193538796-10a19846-91a9-4e26-a19f-f513db7f4deb.png
Here the 'rightarrow' is pasted.
Thanks!
1. Create a math block using $ in a note. Like, $G: x z$
2. Copy a text from a website, like 'Your personal
research assistant' from https://www.zotero.org/.
3. Click the math block to enter edit mode(now the text is purple and the background is grey).
4. Ctrl+C to paste the copied text between x and z. The copied text(Your personal
research assistant) is in white and the background is black.
5. Leave edit mode. The math only displays G:x.
That's how to reproduce. I guess when you paste to a math block, the pasted content should be pure text.
BTW, redo/undo cannot be used in math blocks. Hope that could be enabled too.
Thank you very much!