# Explicit space character?

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?

-

## 3 Answers

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

\documentclass{article}

\begin{document}

An explicit space: a\textvisiblespace b

\end{document}


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}


-
that's pretty cool. Is there an easy way to control the amount of space to its left and right? I use this in monospace, and it gets too close to its right neighbour. –  lenz Jun 20 '13 at 13:03
@lenz please feel free to open a new question. –  Gonzalo Medina Jun 20 '13 at 13:49

The simplest way to get it is by printing character 32 in typewriter font:

 \texttt{\char32}

-
This relies imho to much on the font encoding. E.g. it won't work if you use xetex/fontspec or if you type in greek (LGR-encoding). –  Ulrike Fischer Apr 5 '12 at 9:01

You can store that character (a squat-u) inside a box and use it as necessary:

\documentclass{article}
\newsavebox{\spacebox}
\begin{lrbox}{\spacebox}
\verb*! !
\end{lrbox}
\newcommand{\aspace}{\usebox{\spacebox}}%
\begin{document}
Hi\aspace there!
\end{document}


You cannot directly store it in a macro, since verbatim content cannot be passed as an argument. However, boxing it via an lrbox environment works. Use the squat-u via \aspace.

-
Thanks for that! –  Josh Chen Apr 5 '12 at 5:11