Edit
I think this differes slightly from the linked "duplicate" as here are paragraphs formatted as typewriter, using \ttfamily
while in the duplicate there are
a lot of "common words" in typewriter font sprinkled around his text.
The solution is of course similar, but "Heiko Oberdiek", marked answer here, gave a nice working example and explanation regarding this problem. Personally I had problems understanding what parts of the suggested codes in the "duplicate" question were necessary to solve my issue.
Original Question
I recently have some bigger texts I want to put into \ttfamily.
However, I noticed wordbreaking isn't really working and did some research to add these lines:
\setlength{\emergencystretch}{2em}
\newcommand{\origttfamily}{}%
\let\origttfamily=\ttfamily%
\renewcommand{\ttfamily}{\origttfamily \hyphenchar\font=`\-}
Also using english option in a memoir-class and babel-package.
This is somewhat helping as there is some wordbreaking and space-stretching happening now, but in the end, most paragraphs are looking more like left-aligned than justified. and there are still some lines going over the defined borders.
Here is a minimal example with 2 longer text-passages, one in plain and one in ttfamily.
\documentclass[english,11pt,oneside,article,a5]{memoir}
\usepackage[english]{babel}
\usepackage{geometry}
\setlength{\emergencystretch}{2em}
\newcommand{\origttfamily}{}%
\let\origttfamily=\ttfamily %
\renewcommand{\ttfamily}{\origttfamily \hyphenchar\font=`\-}
\geometry{left=20mm,right=20mm, top=20mm, bottom=50mm}
\OnehalfSpacing
\leftskip3em\rightskip2em
\begin{document}
$>$She didn’t want to spend the time trying to locate them, or try to thin out the operator’s patience for Alison doing whatever. She expects they are already rather sour at her burrowing a tunnel through most of the building’s floors to make that railgun using an enormous amount of jetalium. If she gets a chance later, though, to come back to this place, she’ll put rescuing Loviro on the table.
\\{}\ttfamily According to the engineer, they are most likely tethers to launch things cheaply into space, given how high they go. Although, Alison does come by close enough to see one to see a revolving restaurant at the top of it, so tossing stuff into space may not be its only function.
\end{document}
Did I to something wrong in using ttfamily like this?