# [NTG-context] Ending strings with non-break space in lang-txt.lua

Hans Hagen j.hagen at xs4all.nl
Thu Dec 6 10:44:32 CET 2018

On 12/6/2018 10:26 AM, Marco Patzer wrote:
> On Thu, 6 Dec 2018 09:34:57 +0100
> Hans Hagen <j.hagen at xs4all.nl> wrote:
>
>>>
>>> \at{\labeltext{atpage}}[#1]
>>
>> indeed, that is the command to use
>
> Don't get too hung up on that command. That was just a quick way to
> demonstrate the point and create an MWE.
>
>> can you experiment with this
>>
>> \unexpanded\def\leftofreferencecontent
>>     {\removeunwantedspaces
>>      \nobreakspace
>>      \ignorespaces}
>
> This fixes the MWE, but it doesn't prevent all "unfortunate" line
> breaks caused by the spaces. At least it doesn't if \labeltext is
> used separately to obtain the translated strings.
>
> Currently I use (in one of my modules):
>
>    \def\foo{\labeltext\v!atpage\currentreferencepage}
>
> This works (as by your suggestion):
>
>    \def\foo{\labeltext\v!atpage
>      \removeunwantedspaces\nobreakspace\ignorespaces
>      \currentreferencepage}
>
> Which basically replaces the space with a non-break space after the
> fact.
>
> So I wonder if it's not a better solution to fix the initial
> definitions. But I might be mistaken or I'm overlooking something
> where this might cause issues.
it then interferes with mechanisms that inject spaces themselves (as
\at{...}[]

(i'll add am auto check space and replace by nonbreak space trick)

Hans

-----------------------------------------------------------------