# Text runs off right margin with \texttt{}

I asked this question earlier and it was linked to other questions and considered closed. I've checked the answers to the linked questions and they don't answer my question so I'm trying again. The following text begins a paragraph. When typeset, the word 'the' in the second sentence breaks the right margin:

Graunt decided to pen a scientific paper to show to Petty. In 1662 he produced
a series of tables based on mortality records. His article was called \texttt{Natural and
Political Observations Mentioned in a Following Index, and Made Upon the
Bills of Mortality.}


I can probably solve it by rewording the preceding text but it would be nice to understand why this is happening here and nowhere else in the document.

New contributor
TonyK is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
• If your question gets closed as a duplicate but you don't think that it's a duplicate, then the normal protocol is to edit our existing question to state how your question is different and why the answers of the other question didn't help you. After you edit a closed question, it gets automatically added to a review queue where are users have the option to reopen the question if they agree with you. Nov 25 at 17:41
• Is there a reason for using \texttt for this? I'd use italics. Nov 25 at 17:43
• Please add the code of a complete document, starting with \documentclass and ending with \end{document}. In particular, it is relevant to know the font, font size, and text width, which should all become clear if you include the relevant parts of your preamble. The issue might be easy to fix by adding some possibilities for breaking long words. Nov 25 at 17:46
• When did you ask this question before and what was the question number? Nov 25 at 18:14
• Probably this one: tex.stackexchange.com/q/623885/107497 Nov 25 at 18:18

I can somehow reproduce the issue:

\documentclass[12pt]{article}

\begin{document}

Graunt decided to pen a scientific paper to show to Petty. In 1662 he produced
a series of tables based on mortality records. His article was called
\texttt{Natural and Political Observations Mentioned in a Following Index,
and Made Upon the Bills of Mortality.}

\end{document}


There are a few things you should know about typewriter type:

1. it sets no flexibility in interword spaces;
2. it is not subject to hyphenation;
3. the interword space is the same as the width of letters;
4. it is totally unfit for this job.

Issue number 4 is independent from the other three, which can be fixed.

\documentclass[12pt]{article}

\newcommand{\opus}[1]{%
\begingroup
\spaceskip=\fontdimen2\font plus \fontdimen3\font minus \fontdimen4\font
\xspaceskip=\fontdimen7\font\relax
\ttfamily
%\hyphenchar\font=\-
#1%
\endgroup
}

\begin{document}

Graunt decided to pen a scientific paper to show to Petty. In 1662 he produced
a series of tables based on mortality records. His article was called
\opus{Natural and Political Observations Mentioned in a Following Index,
and Made Upon the Bills of Mortality.}

\end{document}


You might decide to uncomment the \hyphenchar line (but be advised that all text in typewriter type might get hyphenated).

However, this doesn't solve issue number 4: the result is ugly as hell.

Substitute the definition of \opus with

\newcommand{\opus}[1]{\textit{#1}}
`

and the result will look much better:

Now you can choose.

• Thank you all. I've learned that I should amend my question even if it is closed. That I should post the preamble. And I've learned that texttt doesn't allow adjustment of spacing. All good things to know. I'll switch to italics. Nov 25 at 18:17
• @TonyK You can just remove your closed previous question. Nov 25 at 18:27
• I'm not just a neophyte in LaTeX but on this resource roo. How do I remove a question? Nov 26 at 1:31