0

I noticed that my particular version of texlive (Arch Linux' texlive-core 2021.62793-1) seems to be missing some chars.

In particular, the file

\documentclass{article}  
\begin{document}  
    A{\ttfamily\char32}B\textvisiblespace C
\end{document}

produces this output:enter image description here

However, when I compile the same file on overleaf, it properly displays ttfamily's rendition of a text-visible space between A and B.

enter image description here

Does anyone know why this happens? How can I debug this problem? Where is the definition of the default ttfamily font located in TexLive?

  • I don't have a solution yet, but I notice that the character is indeed missing if I compile with LuaLaTeX, but it's present if I compile with PDFLaTeX. A font-related problem? – Miyase May 10 '22 at 21:11
  • I'm using texlive (texlive-core 2022.63035) on Arch as well and getting the same result. Do you get the character on overleaf with lualatex? – frabjous May 10 '22 at 21:16
  • I'm not sure how relevant it is, but have a look at this comment link that may indicate that \char32 is indeed a rather delicate command. – Miyase May 10 '22 at 21:19
  • Indeed, the issue is that I compiled with PDFLatex once and with XeLatex twice. – JoJoModding May 10 '22 at 21:43

1 Answers1

2

If you compile with pdflatex you get

enter image description here

because the default cmtt10 font has that glyph at slot 32.

If you compile with XeLaTeX or LuaLaTeX you get

enter image description here

because the default Latin Modern Typewriter font has a blank space at slot 32.

That's the main reason why LaTeX defines \textvisiblespace. The big advantage is that you can redefine it to suit your needs.

For instance, you could do

\documentclass{article}
\usepackage{iftex}

\iftutex \DeclareRobustCommand{\textvisiblespace}{\texttt{\symbol{"2423}}} \else \DeclareRobustCommand{\textvisiblespace}{\texttt{\symbol{32}}} \fi

\begin{document}

B\textvisiblespace C

\end{document}

to get, with all engines,

enter image description here

egreg
  • 1,121,712