[Tex/LaTex] Entire document typed in monospace font

punctuationspacingtypewriter

I want to put an entire document into monospace font for various reasons. This is nominally fairly easy; you can say \renewcommand{\familydefault}{\ttdefault}. However, there at least two problems with this approach (and possibly more). Thus, my question is really three separate ones:

  1. So far, I'm having a problem with the spaces not working as they should; this seems to be fixed by \obeyspaces, but I am unsure of how well this really works. The only references to it I could find were on this site, and they didn't really explain that command well. Could you please provide a reference for this or at least explain what the command does and what its limitations are?
  2. My other problem is that sometimes LaTeX generates symbols (such as smart quotes), and these do not obey the monotype spacing. LaTeX even seems to generate these when the symbols are in the font used. Is there any way of finding out when this happens, and preferrably of telling LaTeX to use existing characters when possible? Update: This is not a problem at all; see below.
  3. I have found these by myself, but it seems quite likely that there are other problems as well. Are there other things I should look out for, like accented characters? Bold seems to work correctly (at least in the Courier font), but will all such formatting?

Update: In case it is relevant (which, now that I think of it, it almost certainly is), I am using XeTeX and fontspec. I would prefer to keep this setup, but would be open to not using fontspec or to using pdflatex instead.

Update 2: The "smart quotes" problem was actually a problem with spaces after punctuation. I turned on French spacing, but this just emphasizes the need for part three of my question.

Best Answer

The easiest (but not the most flexible) way is to use memoir with the ms option. Then you get something that look like a good, old typewriter manuscript.

memoir also hard code the monospace font to be cmtt, se line 12643 in the memoir.cls. If you want another monospaced font, you need to change at least the lines:

\renewcommand{\familydefault}{cmtt}
\renewcommand{\rmdefault}{cmtt}
\renewcommand{\sfdefault}{cmtt}
\renewcommand{\bfdefault}{m}
\renewcommand{\itdefault}{n}
\renewcommand{\sldefault}{n}
\renewcommand{\scdefault}{n} 

Changing to scaled luximono:

\usepackage[scaled=0.85]{luximono}
\input{glyphtounicode}
\pdfgentounicode=1
\renewcommand{\familydefault}{ul9}
\renewcommand{\rmdefault}{ul9}
\renewcommand{\sfdefault}{ul9}
\renewcommand{\bfdefault}{m}
\renewcommand{\itdefault}{n}
\renewcommand{\sldefault}{n}
\renewcommand{\scdefault}{n}

I also recommend the package csquotes to ensure correct quoting marks.

EDIT: I forgot that you preferred XeLaTeX and it sems that memoir and the ms-option does not work with XeLaTeX.

Here is a new (near) MWE:

\documentclass[english,ms,11pt]{memoir}
  \usepackage{babel}
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenx}

  \usepackage{lmodern}
% Comment the line above and uncomment the following
% ten line to change monotype font.

%\usepackage[scaled=0.85]{luximono}
%\input{glyphtounicode}
%\pdfgentounicode=1
%\renewcommand{\familydefault}{ul9}
%\renewcommand{\rmdefault}{ul9}
%\renewcommand{\sfdefault}{ul9}
%\renewcommand{\bfdefault}{m}
%\renewcommand{\itdefault}{n}
%\renewcommand{\sldefault}{n}
%\renewcommand{\scdefault}{n}

\usepackage[autostyle=true]{csquotes} 
\usepackage{lipsum,kantlipsum} 

\begin{document}

\lipsum[2]

\end{document}

Computer Modern

Computer Modern

Scaled Luximono
enter image description here