[Tex/LaTex] \texttt overfull hbox problem

line-breakingtypewriter

I asked a question earlier about \verb and overfull hbox :
In-line \verb — overfull hbox problem

And regarding the solution there, changed many of my \verbs to \texttt{}s. I have come up with a new problem now. An example:

\documentclass {article}
\begin{document}
\section {Introduction}

    The entry point is in \texttt{TRCS.Main()} (\texttt{TRCS\char`\\TRCS.cs}). 
  The stateless (see \S 3.4.3) forms are started immediately, then another controller
  is invoked, namely  \texttt{Workflow}.
\end{document}

Compiling this example will show my problem. \texttt{Workflow} causes an overflow, and a rather significant one. What should I do to alleviate the problem? Thanks in advance for your help!

Best Answer

Informally speaking, TeX break lines at spaces (and a few other positions in a word, called "discretionary break"). Discretionary break is not allowed in typewriter typesetting. If there is no space in \texttt{}, it cannot break.

For your example, there is no help using \texttt instead of \verb. There are several ways to solve such kind of problem:

  1. Enable microtype for pdfTeX (suggested):

    \usepackage{microtype}
    
  2. Enable hythenation of TT text:

    \usepackage[htt]{hyphenat}
    
  3. Use a sloppy paragraph:

    \sloppy
    

    or

    \begin{sloppypar}
    The entry point is...
    \end{sloppypar}
    

    This may cause bad spacing.

  4. Enable break manually:

    \texttt{Work\allowbreak flow}
    

    This is not useful here, but may be useful for \texttt{TRCS.\allowbreak Main()}