dendronhq / dendron

The personal knowledge management (PKM) tool that grows as you do!
https://wiki.dendron.so
Apache License 2.0
6.68k stars 252 forks source link

Embedded LaTeX for better Table functionality #665

Open funnym0nk3y opened 3 years ago

funnym0nk3y commented 3 years ago

Please Select if your Request is Either something new or an Enhancement

Please select the area your request applys to. (Multiple selections are Possible)

Is your feature request related to a problem? Please describe

I'm using a lot of tables in my notes. For basic tables this is fine, but for more complex ones markdown gets to it's limits. The two solutions are either embedding HTML-tables with all the bells and whistles which also requires CSS or to include the table as an image (which separates the information to different files).

Describe the solution you'd like

Therefor I'd like to propose a mode/module/etc which lets me write pure LaTeX code inside the markdown document for tables (and possibly diagrams) which then gets converted to HTML and embedded in the markdown. I thought of pandoc there but can't say anthing about the feasibility. Ideally it should use the style of the rendered markdown.

Describe alternatives you've considered

Another solution could be to allow dendron to also manage LaTeX documents. But that does not allow a combination of say embeddd multimedia and TeX.

ghost commented 3 years ago

I have a question for this would you want to write the LaTeX directly inside the markdown, or would you accept having to put it inside a Codeblock with a Corresponding title that tells it to render the LaTeX?

funnym0nk3y commented 3 years ago

A codeblock or a decorator was what I had in mind, like for example:

text

@latex_extern {
latex code
}

text

What would be really important is the support to load packages and define macros to extend KaTeX/Mathjax.

b0xian commented 3 years ago

while it is likely less overall useful, in some ways i think adapting this obsidian plugin for increasing dendron table functionality

funnym0nk3y commented 3 years ago

@b0xian Does this allow additional formatting of the tables like merged cells and so on? Becaus I think that is limited by markdown itself. Or ist this "just" a ergonomics tool?

@kpathakota Maybe a split of this issue is needed: One that focuses on markdown tables and one that focuses on general LaTeX support?

kpathakota commented 3 years ago

@funnym0nk3y - yes, I see what you mean. There's probably going to be a time down the line that we upgrade tables to be first-class citizens within Dendron but I don't think we're there yet (would require some significant design thinking to make sure it's compatible with Markdown + frontmatter + easy to use).

Is this just a bug with our previewer that it's not able to handle LaTeX (even though it handles smaller expressions) or do you think this will be net-new functionality?

funnym0nk3y commented 3 years ago

I don't think additional table styling is possible with standard markdown. But maybe I'm wrong. The ergonomic tools @b0xian is working on are great though.

My thought was the following:

Under the impression that markdown has limited table functionality and the issue with not conforming to specification if anything more advanced is added I thought of integrating latex. The current latex implementation (KaTeX and Mathjax I think) does not allow for inclusion of arbitrary packages from CTAN, but has the advantage of better browser compatibility. I tried to include siunitx into Mathjax but failed (see discussion). Roughly my wish was to integrate a separate latex mode, which could require a latex installation and takes arbitrary latex code, compiles it and then uses pandoc to embed it into the note/document. That would be a completely new feature. Extending the current KaTeX/Mathjax implementation to allow for user defined macros would still be nice though.

kpathakota commented 3 years ago

@funnym0nk3y - got it. Yeah, the separate latex install is a larger scoped item. Will see if we can work through this once the #643 is complete.

aleksey-rowan commented 3 years ago

I also need come comprehensive tables, specifically tables supporting more than a single line per cell. As @funnym0nk3y said, you can either write it as an HTML table, or user br tags to break the lines inside a cell. Both approaches make it very hard to work with the table in the editor (with br tags it's particularly bad as you need to scroll horizontally all the time to see anything).

There doesn't seem to be a good (or any sane) way to have a multiple lines in cell with Commonmark and their discussion on extending the standard to include a more complex table seems to have gone nowhere for years. I was going to suggest that maybe Dendron could add support for reStructuredText tables or AsciiDoc tables which do provide more formatting options than pure Markdown.

Writing tables in LaTeX seems like an even better alternative, but would we be able to insert Dendron wiki-links into LaTeX tables given they are inside codeblocks?

jsamr commented 2 years ago

I would personally rather see support for either pure reStructuredText or AsciiDoc documents instead of non-standard MD syntax extensions which would poorly integrate with the VSCode ecosystem. Love how AsciiDoc handles tables! As for LaTex, it is very environment dependent with a library system and multiple compilers; that seems utterly too complex.

micharris42 commented 2 years ago

I think @jsamr has the right idea. If you will forgive the gross generalization, basic Markdown covers 90% of use cases for 90% of users. If your needs fall outside of that, you probably should just use another markup language.

Rather than trying to force multiple languages into one document, I think the modular approach seems like a better choice. Let Dendron users use .md files as long as those meet their needs. Then when they need something more robust, give them the option to add another format—for example, an .adoc file—to their vault.

Everyone who does not need the extra formatting does not have to think about it, and everyone who does has a relatively easy alternative.