[luatex] The effect of \pardir and \textdir on \indent and \parfillskip

Ulrike Fischer luatex at nililand.de
Wed Dec 12 16:27:34 CET 2012


Am Wed, 12 Dec 2012 09:03:26 +0000 schrieb Joseph Wright:

> Hello all,
> 
> Continuing my attempts to understand RTL primitives in LuaTeX, I've come
> across what I'd regard as unexpected behaviour in terms of the
> relationship between \textdir and \pardir.
> 
> For example, in the demo
...
>   \pardir TRT
>   Hello world Hello world Hello world Hello world Hello world
>   Hello world Hello world Hello world Hello world Hello world
>   Hello world Hello world Hello world Hello world Hello world
>   Hello world Hello world Hello world Hello world Hello world
>   Hello world Hello world Hello world Hello world Hello world
...
> 
> I find it surprising that the middle paragraph has the \indent on the
> left, and that it's necessary to alter the text direction to get it on
> the right.

Not only the indent is on the left. If you change the text to

\pardir TRT
  A-Hello world Hello world Hello world Hello world Hello world
  Hello world Hello world Hello world Hello world Hello world
  Hello world Hello world Hello world Hello world Hello world
  Hello world Hello world Hello world Hello world Hello world
  Hello world Hello world Hello world Hello world Hello world-Z

You can see that also the "A" is on the left (and the Z on the
right). So the direction of words are not changed. Only the lines
are moved to the right -- which hasn't much effect on lines with a
width equal to textwidth.

But the effect can be seen better when the lines are ragged:

\documentclass{article}
\directlua {
tex.enableprimitives('',{'pagedir','bodydir','pardir','textdir','mathdir'})
}
\begin{document}
 \raggedright
   R-Hello world \\
   R-hello\\
   R-hello
  \par

 \raggedleft
  L-Hello world \\
  L-hello\\
  L-hello
  \par
 


 \pardir TRT
 \raggedright
   R-Hello world \\
   R-hello\\
   R-hello
  \par

 \raggedleft
  L-Hello world \\
  L-hello\\
  L-hello
 \par
 
\end{document}


-- 
Ulrike Fischer 
http://www.troubleshooting-tex.de/



More information about the luatex mailing list