varkor / quiver

A modern commutative diagram editor for the web.
https://q.uiver.app
MIT License
2.41k stars 80 forks source link

`//` for line breaks works in quiver but not in tikzcd #136

Closed AlexanderZeilmann closed 5 months ago

AlexanderZeilmann commented 2 years ago

This diagram contains a // in two nodes. In quiver the line break is rendered, but the LaTeX output

\[\begin{tikzcd}
    multi\\line && other\\node
\end{tikzcd}\]

renders as Bildschirmfoto 2022-01-25 um 12 09 19

Ideally quiver should convert this to a syntax that works with tikzcd.

varkor commented 2 years ago

This should be fairly easy to fix, so long as there's a convenient way to render newlines in tikz-cd. If anyone knows how to do this, please let me know :)

AlexanderZeilmann commented 2 years ago

Wrapping it in an array should work

\begin{array}{c}
multi \\ line
\end{array}

but I have not tested it extensively.

balacij commented 2 years ago

I am using \parbox{3cm}{\centering Something That Is Longer Than Expected} to get multiline working, however, it doesn't render with the mathematical font. I get an error with a normal \\, I'm not quite sure why. \newline and \linebreak are ignored as inputs.

varkor commented 1 year ago

On reflection, this is more difficult than I first thought, since one has to determine which occurrences of \\ are actually newlines, which I believe requires parsing the LaTeX. KaTeX is doing this already, but I'm not sure whether it's possible to extract this information somehow.

However, one can add newlines to diagrams manually using \shortstack.

varkor commented 1 year ago

I think the correct solution here would be to disable new lines in quiver. I'm not sure this is possible yet with KaTeX, so I've opened https://github.com/KaTeX/KaTeX/issues/3773.

varkor commented 1 year ago

Fixed in https://github.com/varkor/quiver/commit/a239252650751968577a981af20ebbea490fe07c (by disabling newlines).

varkor commented 1 year ago

Unfortunately, I had to revert the fix due to the issue reported here: https://github.com/varkor/quiver/issues/163#issuecomment-1546983693.

user202729 commented 5 months ago

There's a discussion of this issue at diagrams - tikz-cd quiver code not working - TeX - LaTeX Stack Exchange . I think the third answer there has an automatic solution that can be implemented in quiver.

varkor commented 5 months ago

@user202729: thanks for the suggestion. I'll look into this issue and #225 this evening.

varkor commented 5 months ago

This is fixed by https://github.com/varkor/quiver/commit/46269555e260cd3da1deb90ebf1a5cd1893fd81c. You can test it out using https://q.uiver.app/dev/.

Let me know if you encounter any issues with it. I will push a new version of quiver when I am happy it is working as intended.