[Tex/LaTex] monospaced fonts not respecting spaces

fontsspacingtypewriter

Why does true type fonts consolidate spaces and is there any way to stop this? I need easily add white space between words equal to the width of a space(which for monospace should be the same for all letters).

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{inconsolata}
\begin{document}
\catcode`_=11
\par\texttt{this is monospaced text    Where  are  the  spaces  ?    !!!}%
\par\texttt{this_is_monospaced_text____Where__are__the__spaces__?____!!!}
\end{document}​

update:

Using \obeyspaces or \verb works BUT something seems to be ruining the spacing:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usepackage{fancyvrb}
\usetikzlibrary{matrix}

\begin{document}
\begin{tikzpicture}%
\matrix (m) [matrix of nodes, every node/.style={font=\ttfamily},%
    row 1/.style={text width=7em, align=left,font=\ttfamily},
    row 2/.style={text width=7em, align=left,font=\ttfamily},]
    {
        \verb+A  B  C  D +\\
        \verb+Ac Ad Be Cf+\\
    };
\end{tikzpicture}
\end{document}​

The output looks like the monspace font is not used.


update2:

Weird behavior: extra spaces between ? and !!!! Breaks the tikz matrix for some reason(remove tikzpicture to get it to work):

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usepackage{fancyvrb}
\usetikzlibrary{matrix}

\begin{document}


\catcode`_=11
\par\obeyspaces{\texttt{this is monospaced text    Where  are  the  spaces  ?    !!!}}%
\par\texttt{this_is_monospaced_text____Where__are__the__spaces__?____!!!}
\catcode`_=8

\begin{tikzpicture}%
\matrix (m) [matrix of nodes, every node/.style={font=\ttfamily},%
    row 1/.style={text width=7em, align=left,font=\ttfamily},
    row 2/.style={text width=7em, align=left,font=\ttfamily},]
    {
        \verb+A  B  C  D +\\
        \verb+Ac Ad Be Cf+\\
    };
\end{tikzpicture}
\end{document}​

Best Answer

Another approach for short verbatim text is to use the \Verb command from the fancyvrb package; I added the obeytabs option and used tabsize to recover the alignment inside the \matrix (the characters are spaced using tabs):

Apparently, when I copy the code from my editor to this site the tabs get lost. You need to use A(tab)B(tab)C(tab)D and Ac(tab)Ad(tab)Be(tab)Cf in the code below, where (tab) stands for a tab in your editor:

\documentclass{article}
\usepackage{fancyvrb}
\usepackage{tikz}
\usetikzlibrary{matrix}

\fvset{obeytabs}

\begin{document}

\begin{tikzpicture}%
\matrix (m) [matrix of nodes, every node/.style={font=\ttfamily},%
    row 1/.style={text width=7em, align=left},
    row 2/.style={text width=7em, align=left}]
    {
\Verb[tabsize=2]+A  B   C   D+\\
\Verb[tabsize=1]+Ac Ad  Be  Cf+\\
    };
\end{tikzpicture}

\end{document}​

enter image description here

Using the \lstinline command from the listings package, there's no need to use tabs; simple spaces will behave as expected:

\documentclass{article}
\usepackage{listings}
\usepackage{tikz}
\usetikzlibrary{matrix}

\begin{document}

\begin{tikzpicture}%
\matrix (m) [matrix of nodes, every node/.style={font=\ttfamily},%
    row 1/.style={text width=7em, align=left},
    row 2/.style={text width=7em, align=left}]
    {
\lstinline+A  B  C  D+\\
\lstinline+Ac Ad Be Cf+\\
    };
\end{tikzpicture}

\end{document}

enter image description here