Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hbox inside equation is problematic #285

Open
Udi-Fogiel opened this issue Feb 17, 2024 · 5 comments
Open

hbox inside equation is problematic #285

Udi-Fogiel opened this issue Feb 17, 2024 · 5 comments
Labels
⚙️ under study Exact behavior to be decided

Comments

@Udi-Fogiel
Copy link
Contributor

Udi-Fogiel commented Feb 17, 2024

see https://tex.stackexchange.com/questions/709365/inline-equation-breaks-when-adding-hebrew-text-with-the-witharrows-package for an example. Here are more minimal example

\documentclass{article}
\usepackage[bidi=basic, hebrew,provide=*]{babel}
\babelfont{rm}{David CLM}
\begin{document}
שלום $\hbox{$abc$ שלום}$
\end{document}
\documentclass{article}
\usepackage[bidi=basic, hebrew,provide=*]{babel}
\babelfont{rm}{David CLM}
\begin{document}
שלום $\hbox{abc שלום}$
\end{document}
@seloumi
Copy link
Contributor

seloumi commented Feb 17, 2024

If \hbox start with hebrew letter we will get a correct result.

\documentclass{article}
\usepackage[bidi=basic, hebrew,provide=*]{babel}
\babelfont{rm}{DavidLibre}

\begin{document}

\begingroup
\everyhbox{‏}% Right-To-Left Mark (U+200F)
שלום $\hbox{$abc$ שלום}$

שלום $\hbox{abc שלום}$
\endgroup

\end{document}

@jbezos
Copy link
Contributor

jbezos commented Feb 17, 2024

@Udi-Fogiel @seloumi Thanks. I usually take a short break when TeXLive is about to be published (I don't like to make any last minute changes, unless it's a severe bug). When it's frozen, I'll start investigating.

@jbezos
Copy link
Contributor

jbezos commented Mar 7, 2024

The title summarizes very well the whole point here: \hbox inside equation is problematic. I copy here what I wrote in tex.stackexchange.com:

I’m trying to find a general solution, but below there is as a workaround [...]. Why is this happening? Well, it’s related with the fact \hbox’es [...] are used internally for quite a lot of purposes and there is no way to know if they contain real text or serve to build some special combination of letters, symbols, graphics, etc. Babel attempts to guess how to deal with them, but it may fail.

@Udi-Fogiel
Copy link
Contributor Author

it’s related with the fact \hbox’es [...] are used internally for quite a lot of purposes and there is no way to know if they contain real text or serve to build some special combination of letters, symbols, graphics, etc. Babel attempts to guess how to deal with them, but it may fail.

I think it would be much easier to solve it upstream (at least in the case of big packages such as tikz). \hboxes meant for intrinsic LTR material could be flagged using a reserved attribute, or use \hpack instead of an \hbox so that the code that babel add to the hpack_filter callback won't affect this box.

@jbezos
Copy link
Contributor

jbezos commented Mar 8, 2024

I think it would be much easier to solve it upstream (at least in the case of big packages such as tikz). \hboxes meant for intrinsic LTR material could be flagged using a reserved attribute, or use \hpack instead of an \hbox so that the code that babel add to the hpack_filter callback won't affect this box.

Indeed, in an ideal world— 🙂. But even \put in the humble picture can be used to place either text or graphics (or both). So, I’m thinking of a helper function like the following, which can be useful in the meanwhile:

\documentclass{article}
\usepackage[bidi=basic, hebrew, provide=*]{babel}
\babelfont{rm}{David CLM}

\makeatletter
\newcommand\localebox[1]{%
  {\def\bbl@insidemath{0}%
   \mbox{\foreignlanguage{\languagename}{#1}}}}

\begin{document}

אחת שתיים $\localebox{$abc$ שלום}$

אחת שתיים $\localebox{abc שלום}$

אחת שתיים $\mbox{abc שלום}$ % Just to compare

\end{document}

@jbezos jbezos added the ⚙️ under study Exact behavior to be decided label Mar 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚙️ under study Exact behavior to be decided
Projects
None yet
Development

No branches or pull requests

3 participants