flutter_tex icon indicating copy to clipboard operation
flutter_tex copied to clipboard

support for arabic inside latex

Open 1FarZ1 opened this issue 8 months ago • 2 comments

im facing issue rendering arabic latex , any work arounds ?

1FarZ1 avatar Apr 28 '25 06:04 1FarZ1

Try the latest version flutter_tex: ^5.0.1 and use the newly introduced widget TeXWidget (see example). It's not based on webview, so I hope you can use inline Arabic.

Shahxad-Akram avatar May 05 '25 22:05 Shahxad-Akram

What worked for me is to wrap the content within the TeXViewDocument's body string with an HTML div using dir="rtl" and applying CSS to preserve whitespace and newlines. Example:

<style>
  .preserve-lines {
    white-space: pre-wrap; /* Preserves whitespace & newlines, wraps text */
    /* Or: white-space: pre-line; // Collapses multiple spaces, preserves newlines & wraps */
  }
</style>

<div dir="rtl" class="preserve-lines">
هذا mix بين \(\left( u_{n} \right)\) عربية and أخرى english.
لتكن \(\left( u_{n} \right)\) متتالية عددية.
\[u_{n + 1} = \frac{1}{2}u_{n} + 1\]
</div>

Pass this HTML string as the body to a TeXViewDocument. The dir="rtl" handles the text direction, and white-space: pre-wrap; (or pre-line;) ensures Arabic text formatting and line breaks are respected around the inline math.

This setup allowed mixed English, Arabic, inline math, and display math to render correctly.

MerwanCB avatar May 25 '25 13:05 MerwanCB