[Tex/LaTex] How to force LaTeX to ‘hyphenate’ (monospaced font)

hyphenationmarginstypewriter

How can I force LaTeX to 'hyphenate' the following text? Such that the margins are not overridden (see picture). Is there a way to prevent this?

enter image description here

Edit: This is the file after adding –

enter image description here

\documentclass[12pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{lmodern}
\geometry{a4paper,left=25mm,right=25mm, top=2cm, bottom=2cm} 
\begin{document}
\noindent \texttt{LinearDiscriminantAnalysis}, \texttt{QuadraticDiscriminantAnalysis}, \texttt{Perceptron}, \texttt{GaussianNB}, \texttt{LogisticRegression}, \texttt{DecisionTreeClassifier}, \texttt{SVC}, \texttt{MLPClassifier} and \texttt{KNeighborsClassifier}.\\
\\
Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\end{document}

Best Answer

(edited answer to incorporate OP's second, supplemental example)

As David Carlisle has already observed in a comment, LaTeX doesn't "do" hyphenation with monospaced font faces. However, this can be overridden by inserting \- hyphenation points. Assuming that it's ok to hyphenate GaussianNB as Gaus\-sian\-NB, and assuming further that it's permissible to exchange the ordering of the final two terms, the following solution gets the job done. A similar approach works with the OP's second example as well.

enter image description here

\documentclass[12pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\geometry{hmargin=25mm, vmargin=2cm} 
\usepackage{lmodern}
\usepackage[ngerman]{babel}

\begin{document}
\hrule % just to illustrate width of textblock

\smallskip\noindent 
\texttt{LinearDiscriminantAnalysis}, 
\texttt{QuadraticDiscriminantAnalysis}, 
\texttt{Perceptron}, 
\texttt{Gaus\-sian\-NB}, 
\texttt{LogisticRegression}, 
\texttt{DecisionTreeClassifier}, 
\texttt{SVC}, 
\texttt{KNeighborsClassifier} and % exchange order of final two terms
\texttt{MLPClassifier}.

\medskip\noindent 
portiert werden. Hierzu z"ahlen die Klassen
\texttt{LinearDiscriminantAnalysis}, 
\texttt{Quadratic\-DiscriminantAnalysis}, 
\texttt{Perceptron}, 
\texttt{GaussianNB}, 
\texttt{LogisticRegression}, 
\texttt{SVC}, 
\texttt{Deci\-sion\-TreeClassifier}, 
\texttt{MLPClassifier} and 
\texttt{KNeighborsClassifier}.
Zur Bestimmung der G"ute werden zus"atzlich 
die zwei Hilfsklassen 
\texttt{confusion\_matrix} und
\texttt{accuracy\_score} importiert. 

\end{document}