Cannot make linebreaks in mathematical formula using KaTeX
See original GitHub issueI’m trying to create an Android vidget that shows mathematical formula, using KaTeX library and WebView. The problem is that I cannot configure it to automatical wrapping of formulae, that are bigger, than screen.
My java code:
WebView webView = new WebView(SpaceActivity.this);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
webView.setPadding(2, valueViewer.getTextPadding(), 2, valueViewer.getTextPadding());
String html = "<!DOCTYPE html>\n" +
"<html>\n" +
" <head>\n" +
" <meta charset=\"UTF-8\">\n" +
" <title>Auto-render test</title>\n" +
" <link rel=\"stylesheet\" type=\"text/css\" href=\"file:///android_asset/katex/katex.min.css\">\n" +
" <script type=\"text/javascript\" src=\"file:///android_asset/katex/katex.min.js\"></script>\n" +
" <script type=\"text/javascript\" src=\"file:///android_asset/katex/contrib/auto-render.min.js\"></script>\n" +
" </head>\n" +
" <body>\n" +
" " + expression + // variable, containing formula in TeX-format
" <script>\n" +
" renderMathInElement(\n" +
" document.body\n" +
" );\n" +
" </script>\n" +
" </body>\n" +
"</html>";
webView.getSettings().setSupportZoom(true);
webView.loadDataWithBaseURL("file:///android_asset/", html, "text/html", "utf-8", null);
Earlier I used MathJax library, but it is much slower than KaTeX, plus, when I give new formula to MathJax-related vidget, it flashes and diddles, making unbeautiful performance.
How can I configure KaTeX for line wrapping?
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Why does \\ not return a new line in an equation?
Both equation and equation* do not allow multi lined expressions. Use aligned from amsmath , inside equation* to break in to many lines....
Read more >How can I have linebreaks in my long LaTeX equations?
I would question if you really want to do that. Multi-line equations will be very difficult to read. Is it possible to break...
Read more >Common Issues
KaTeX does not support the align environment because LaTeX doesn't support align in math mode. The aligned environment offers the same functionality but...
Read more >Solved: Newline within Latex/Katex editing mode
Yes, I am aware that "\\" will insert a newline in the rendered math. I am asking to insert newlines in the Latex...
Read more >LaTeX Error: There's no line here to end
In the above example, a line-break has been inserted with no text before it. LaTeX doesn't know what to do since it cannot...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Closing this, as it’s represented by other requests for automatic line breaking in display math (e.g. #1023), and discussion seems to have ended. If you need further help, feel free to post again.
It wraps on katex.org if you turn off displayStyle in the settings menu (click on the gear). This is the equivalent of using
$instead of$$.