# 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?

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.

Another option using fancyvrb:

\documentclass{article}
\usepackage{fancyvrb}
\fvset{showspaces=true}
\SaveVerb{verbspace}! !
\newcommand{\aspace}{\UseVerb{verbspace}}%
\begin{document}
Hi\aspace there!
\end{document}

• The output is very nice but when I use it inside a hidden item in beamer, it remains visible. – yannis May 25 '19 at 10:47
• @yannis: Can you show an example? – Werner May 25 '19 at 16:06
• In beamer: \begin{frame}[fragile]\frametitle{Title}\begin{itemize}\item<1-2>Blabla, \item<2>Bla\aspace bla\end{itemize}\end{frame}, then when the second item is supposed to be invisible, the explicit blank space will remain visible. – yannis Jun 1 '19 at 17:50

Unicode character uni2423 is present in a number of TeX fonts (Stix, Latin Modern Roman, a few others). If you are using LuaLaTeX or XeTeX, you can call the character directly, or paste it from a character map.

This is not necessarily better than the methods discussed in other replies. It is just another way to do it. Let's see if it works here. If you see the character between A and B below (pasted from character map), it means your browser's font has it (mine does):

A␣B

This method also works in LuaLaTeX and XeTeX as \verb|A␣B| as long as the font has the symbol.