Menu

#177 Non-breaking space is too wide

Future
open
nobody
None
5
2020-10-12
2020-10-12
Anonymous
No

This is my first take at XeLaTeX so maybe I’m missing something, but I figure inserting a non-breaking space (U+00A0) results in a too wide space on the PDF. I would expect the width to be the same as a normal (non extended) space, and at the least as the same as the result of the ’~’ TeX command.

Minimal working example :

\documentclass{report}

\begin{document}
\noindent
| | normal space (U+0020)\\
| | non-breaking space (U+00A0)\\
|~| \TeX non-breaking space ($\sim$)\\
| | thin space (U+202F)\\
|\,| \TeX thin space (\textbackslash,)
\end{document}

Discussion

  • Jonathan Kew

    Jonathan Kew - 2020-10-12

    It depends on the font being used; unless you (or some macro package) defines it in another way, U+00A0 will simply print that character from the current font. Some fonts (rather weirdly, in my opinion) have a different width for U+00A0 than for U+0020.

    What might be preferable would be to define U+00A0 as a macro, e.g.:

    \catcode"A0 = \active
    \def^^a0{\nobreak\ }
    

    but of course this may depend on what other packages etc are in use.

    Alternatively, try another font. For example, if I add

    \usepackage{fontspec}
    \setmainfont{Times New Roman}
    

    to your example, the widths of U+0020 and U+00A0 match as you'd expect.

     
  • Anonymous

    Anonymous - 2020-10-12

    Thanks, that makes sense and works indeed. I’m a bit surprised because that means TeX’s ’~’ doesn’t insert U+00A0 (I guess it just inserts some fixed-width blank space then ? Anyway that’s out of the scope of this ticket.)

     
  • Jonathan Kew

    Jonathan Kew - 2020-10-12

    Plain TeX's ~ is just an active-character macro defined as \def~{\nobreak\ }, so my suggestion was simply to make U+00A0 do the same thing.

     

    Last edit: Jonathan Kew 2020-10-12

Anonymous
Anonymous

Add attachments
Cancel