# [texhax] checking if a piece of text stays on one line or more than one line

Vafa Khalighi vafaklg at gmail.com
Tue Oct 11 12:06:58 CEST 2011

```for LTR lines in the aux file, I get:

\zref at newlabel{mytextbf at beg@1}{\posx{10778689}\posy{42091806}}
\zref at newlabel{mytextbf at end@1}{\posx{18087431}\posy{42091806}}
\zref at newlabel{mytextbf at beg@2}{\posx{21938805}\posy{42091806}}
\zref at newlabel{mytextbf at end@2}{\posx{13999838}\posy{41305374}}
\zref at newlabel{mytextbf at beg@3}{\posx{15152478}\posy{41305374}}
\zref at newlabel{mytextbf at end@3}{\posx{22568158}\posy{41305374}}

but for RTL lines, I get:

\zref at newlabel{mytextbf at beg@2}{\posx{0}\posy{0}}
\zref at newlabel{mytextbf at end@1}{\posx{18270151}\posy{42091806}}
\zref at newlabel{mytextbf at beg@1}{\posx{22121525}\posy{42091806}}
\zref at newlabel{mytextbf at end@3}{\posx{29430267}\posy{42091806}}
\zref at newlabel{mytextbf at beg@3}{\posx{17640798}\posy{41305374}}
\zref at newlabel{mytextbf at end@2}{\posx{25056478}\posy{41305374}}

On Tue, Oct 11, 2011 at 8:52 PM, Vafa Khalighi <vafaklg at gmail.com> wrote:

> Thanks heaps. This is what I tried but still the color range is wrong. I am
> using xecolor which uses xetex font color feature so it has no problem in
> RTL.
>
>
> On Tue, Oct 11, 2011 at 8:02 PM, Heiko Oberdiek <
>
>> On Tue, Oct 11, 2011 at 07:40:27PM +1100, Vafa Khalighi wrote:
>>
>> > This is wonderful. I still do not know why it is not working for right
>> to
>> > left text but I will investigate that. I have another question:
>>
>> You have to change the test for the horizontal x-position.
>> How it can be tested, whether the current text mode is
>> right to left or left to right?
>>
>> > Now suppose that we test the argument of \mytextbf and our test shows
>> that
>> > the text inside \mytextbf stays on more than one line, in this
>> condition,
>> > would it be possible to automatically insert
>> >
>> > 1) \foo at beginning of \mytextbf
>> > 4)\foot at the end of \mytextbf
>>
>> Yes, both easy, change the line with \textcolor{red} to your needs:
>>  \textcolor{red}{#1} => \foo#1\foo
>>
>> > 3)\foo at the beginning of each line
>> > 2) \foo at the end of each line
>>
>> No. Then you have to use LuaTeX that allows the modification of
>> node lists even after typesetting (assuming \foo does not change,
>> how the lines are broken across lines).
>>
>> Maybe yes, but expensive. Look at soul, it can split a text
>> in unbreakable portions (at hyphenation points). Then you have
>> to add labels for *each* portion. Then you have the positions of
>> the portions and know, where a line starts and ends.
>>  This may work (within the limitations of package `soul',
>> see its documentation) with small texts. But for larger uses,
>> keep in mind that the hash table in TeX is limited.
>>
>> Yours sincerely
>>  Heiko Oberdiek
>> _______________________________________________
>> TeX FAQ: http://www.tex.ac.uk/faq
>> Mailing list archives: http://tug.org/pipermail/texhax/