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

With graphics layout TeX can't break line containing successive \tikz drawings #213

Closed
seloumi opened this issue Jan 6, 2023 · 9 comments
Labels
🐞 bug Something isn't working has workaround

Comments

@seloumi
Copy link
Contributor

seloumi commented Jan 6, 2023

\documentclass{article}
\usepackage{tikz}

\usepackage[bidi=basic,arabic,provide=*,layout=graphics]{babel}

\parindent=0pt

\newcommand{\tikzcircle}{\tikz[baseline=-0.5ex]{\node[draw=red,circle,minimum width=2em,align=center] at (0,0) {1};}\hspace{5pt}}

\begin{document}

\foreach \x in {1,...,30}{%
\tikzcircle
}%

\end{document}
@u-fischer
Copy link
Member

Why do you use \hspace* instead of simply \hspace?

@seloumi
Copy link
Contributor Author

seloumi commented Jan 7, 2023

@u-fischer I have updated my question

@FrankMittelbach
Copy link
Member

FrankMittelbach commented Jan 7, 2023

somehow the \hspace is not generating a breakpoint which is suprising but I haven't looked why. It does break if you add an explicit breakpoint though, e.g. \allowbreak\hspace{5pt}.
I don't understand enough of the workings of direction changes but it looks as if

.\enddir TLT
.\glue 5.0
.\begindir TLT

is not allowing a break at the glue, ie the direction change preventing the glue from being seens as the "first glue in a sequence". That may be documented somewhere, but perhaps this is actually an engine bug.

@jbezos jbezos added 🐞 bug Something isn't working has workaround labels Jan 8, 2023
@jbezos
Copy link
Contributor

jbezos commented Jan 8, 2023

It’s wrong with bidi=default, too, so it could be indeed an engine bug.

@Udi-Fogiel
Copy link
Contributor

Udi-Fogiel commented Jun 2, 2023

This is not a bug, but a feature. See section 3.3.3 of LuaTeX's manual (Controlling glue with \breakafterdirmode):

\breakafterdirmode=1

\documentclass{article}
\usepackage{tikz}

\usepackage[bidi=basic,arabic,provide=*,layout=graphics]{babel}

\parindent=0pt

\newcommand{\tikzcircle}{\tikz[baseline=-0.5ex]{\node[draw=red,circle,minimum width=2em,align=center] at (0,0) {1};}\hspace{5pt}}

\begin{document}
	
	\foreach \x in {1,...,30}{%
		\tikzcircle
	}%
	
\end{document}

@jbezos
Copy link
Contributor

jbezos commented Jun 2, 2023

@Udi-Fogiel Thank you. Because of the way bidi works in babel, very likely this ‘mode’ must be set to 1. I’ll investigate.

@jbezos
Copy link
Contributor

jbezos commented Jun 3, 2023

@Udi-Fogiel After investigating a bit further, I still think it’s a bug or at least a misfeature. Some\...mode parameters are used to fix bugs without breaking old code. I reported a couple of bugs (or misfeatures) which are only fixed if you change the corresponding \...mode (eg, \matheqdirmode).

@Udi-Fogiel
Copy link
Contributor

@jbezos You are probably right. I did not noticed they fixed the spacing problem around displayed math (with \matheqdirmode), thank you for pointing that out!

If this mode was added for backwards compatibility, should babel just set this to 1? couldn't that change the output of old documents? personally, I think that it should, but I know that LaTeX users often take high value for backwards compatibility.

Sorry if this is not the correct place to discuss this. But, discussing about bugs in LuaTeX's directionality and their fix, I've noticed there is weird behavior for \leqno and \eqno when \pardir and \textdir are differ from \pagedir and \bodydir. Is there some mode that fix that?

I've noticed that with babel the problem does not really exists, so I was wondering how did you deal with that.

@jbezos
Copy link
Contributor

jbezos commented Jun 3, 2023

@Udi-Fogiel I think a bug or even a clearly counter-intuitive behavior should be fixed. This wouldn’t be the first time babel introduces such a change (and \matheqdirmode is an example).

Dealing with intrinsically ‘mixed’ stuff (graphics, math and tabular) is not trivial, because we I can’t know what a box actually contains. See for example #221. Currently, standard LaTeX math is patched by babel to get the label positioning and the vertical space right (\matheqdirmode=1 fixes the vertical spacing, which by default is buggy).

babel keeps track of the direction in three ways: with the luatex/omega primitives, at the TeX level with some macros, and as an attribute in each node (Unicode requires in fact 3 directions for bidi, namely, L, R (Hebrew) and AL (Arabic)).

@jbezos jbezos closed this as completed in 9929c1f Jun 25, 2023
jbezos pushed a commit that referenced this issue Jul 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working has workaround
Projects
None yet
Development

No branches or pull requests

5 participants