Katex: Paragraphs in KaTeX

Created on 23 May 2018  路  9Comments  路  Source: KaTeX/KaTeX

What's the best way to implement a paragraph of text using KaTeX. Googling results in things like:

\begin{document}
This is the first paragraph, contains some text to test the paragraph
interlining, paragraph indentation and some other features. Also, is 
easy to see how new paragraphs are defined by simply entering a double 
blank space.

Hello,  here  is  some  text  without  a  meaning.   This  text  should
show what a printed text will look like at this... 
\end{document}

However, I don't believe this is supported by KaTeX. Is there another way?

discussion

Most helpful comment

I dont think having this directly in KaTeX is a good idea at this point, because once you start with overall document structure, you will have to incorporate all other TeX features revolving the documents (figures, labels, tables, floating environments, lists, etc.) will lead to opening Pandora's box.

I think it's more advisable to have Markdown + KaTeX and transform it into HTML, than full blown LaTeX on HTML documents.

All 9 comments

KaTeX doesn't support top/text-level LaTeX. Maybe it could one day, but this would be a major undertaking.

If you just want automatic paragraph support, you can do this (at the string level, or via innerHTML) via the simple regular-expression substitution .replace(/^|\n\n+/g, '<p>'). HTML already ignores double spaces, newlines, etc., so that's all you need. Are there other features you want?

A detailed hackish approach to supporting much more of top-level LaTeX (via a lot more regexs) is here: https://github.com/edemaine/coauthor/blob/master/lib/formats.coffee

I dont think having this directly in KaTeX is a good idea at this point, because once you start with overall document structure, you will have to incorporate all other TeX features revolving the documents (figures, labels, tables, floating environments, lists, etc.) will lead to opening Pandora's box.

I think it's more advisable to have Markdown + KaTeX and transform it into HTML, than full blown LaTeX on HTML documents.

I think it's a good goal for KaTeX version 2. :-) (We're currently on version 0.)

I'd agree. It sounds like this is completely out of scope.

As a followup, are there any environments that KaTeX supports which would simulate a simple paragraph?

For example: array, matrix, etc.?

In other words, is there a way to hack it together using pure katex, without html?

To help provide some context, I created a Canvas renderer which uses KaTeX's rendering data (pretty much matches all test-cases at this point). Unfortunately, I don't have access to the dom for my specific use case :(

I'm afraid not. You can use array or \\ for simulating paragraphs via manual line breaking. LaTeX has \begin{array}{p{2in}} but KaTeX doesn't support that yet. It's a tough feature to add because KaTeX doesn't have any paragraph breaking support.

We can start a 2.0 milestone to park some of these longer term goals.

I think this might be related to an issue that I am having.
Is there any way to get a blank line between equations?
\bigskip \medskip etc are not supported is there another way?

@andrewcrook would something like the following work for you?
Screen Shot 2020-03-07 at 6 23 09 PM

@kevinbarabash only works using aligned I guess that's how it should be?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mbourne picture mbourne  路  3Comments

janosh picture janosh  路  4Comments

sophiebits picture sophiebits  路  3Comments

jason-s picture jason-s  路  3Comments

trollanfer picture trollanfer  路  5Comments