[Tex/LaTex] Explicit space character

symbols

I'm wondering about the best way to do an explicit space character (I don't even know what it's properly called), like the ones you get in the \begin{verbatim*} environment. The closest I've found is

\sqcup

in math mode, but it seems like a bit of a hack to me. Is there any text symbol for what I'm looking for?

Best Answer

Nothing special is needed here; standard LaTeX provides \textvisiblespace:

\documentclass{article}

\begin{document}

An explicit space: a\textvisiblespace b

\end{document}

enter image description here

A simple variation of the original definition:

\DeclareTextCommandDefault{\textvisiblespace}{%
  \mbox{\kern.06em\vrule \@height.3ex}%
  \vbox{\hrule \@width.3em}%
  \hbox{\vrule \@height.3ex}}

allows to control the width using an optional argument:

\documentclass{article}

\newcommand\Vtextvisiblespace[1][.3em]{%
  \mbox{\kern.06em\vrule height.3ex}%
  \vbox{\hrule width#1}%
  \hbox{\vrule height.3ex}}

\begin{document}

An explicit space: a\textvisiblespace b

An explicit space: a\Vtextvisiblespace b

An explicit 1em space: a\Vtextvisiblespace[1em]b

An explicit 1cm space: a\Vtextvisiblespace[1cm]b

\end{document}

enter image description here