How can I make verbatim's → use a monospace font

Using textcomp is sufficient.

  1. Avoid utf8x that's been unmaintained for several years, whereas utf8 is well maintained and has been extended to cover several character blocks.

  2. Use the T1 output encoding when writing Spanish.

  3. The es-noquoting option is better than deactivating < and > as shorthands.

Now the code.

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc} % needed for Spanish
\usepackage[utf8]{inputenc}
\usepackage[spanish,es-noquoting]{babel}
\usepackage{textcomp}

\begin{document}

\begin{verbatim}
# # # # # ↓ # # # # # # # #   # # #   
#         → → ↓                   #   
#           # ↓     #             #   
#           # → ↓   #             #   
#   # # # # #   ↓         # # # # #   
#             ↓ ←       #         #   
#             ↓         #         #   
#             ↓ # # # # #         #   
#             → → → → → → → ↓     #   
# # # #             #       → ↓   #   
#                   #       # ↓   #   
#                   #       # ↓   #   
#                   #       # ↓   #   
#         #         #         ↓   #   
#         #         # # # # # → → #   
#         #         #       #     #   
#         #                 #     #   
#         #                 #     #   
# # # # # # # # # # # #   # # # # #   
\end{verbatim}

\end{document}

enter image description here

You can use pmboxdraw for the other symbols, provided you use the right ones. Short example:

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc} % needed for Spanish
\usepackage[utf8]{inputenx}
\usepackage[spanish,es-noquoting]{babel}
\usepackage{textcomp}
\usepackage{pmboxdraw}

\pmboxdrawsetup{
  Block/box={\texttt{0}},
}

\begin{document}

\begin{verbatim}
█ █ █ █ █ ↓ █ █ █ █ █ █ █ █   █ █ █
█         └ → ┐                   █
\end{verbatim}

\end{document}

enter image description here


What's happening in your above file is that is defined as \rightarrow, which in turn is defined as a specific (non-monospaced) character.

Instead, with XeTeX or LuaTeX you can use any Unicode characters you like, provided you're using a font that covers those characters. In this case, looking on my system for a monospaced font that covers all the characters mentioned (# ↓ → ← ■ ╚ ╝), I find a number of options (click on image to view it properly):

options

\documentclass{article}
\usepackage{fontspec}
\begin{document}

\begin{verbatim}
whatever `verbatim` uses by default
######
■╚↓→←╝
\end{verbatim}

\setmonofont{Andale Mono}
\begin{verbatim}
Andale Mono
######
■╚↓→←╝
\end{verbatim}

\setmonofont{Courier New}
\begin{verbatim}
Courier New
######
■╚↓→←╝
\end{verbatim}

\setmonofont{Consolas}
\begin{verbatim}
Consolas
######
■╚↓→←╝
\end{verbatim}

\setmonofont{Lucida Console}
\begin{verbatim}
Lucida Console
######
■╚↓→←╝
\end{verbatim}

\setmonofont{Menlo}
\begin{verbatim}
Menlo
######
■╚↓→←╝
\end{verbatim}

\setmonofont{Times New Roman}
\begin{verbatim}
Times New Roman (not a monospace font!)
######
■╚↓→←╝
\end{verbatim}
\end{document}

My preference would be to use an appropriate monospace font, rather than an image.