TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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}
\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}.

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!

share|improve this question
up vote 25 down vote accepted

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):

  2. Enable hythenation of TT text:

  3. Use a sloppy paragraph:



    The entry point is...

    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()}

share|improve this answer
sorry for misspelling. – Leo Liu Feb 6 '11 at 14:59
The tip of \allowbreak was helpful for me. When writing method names in code, I would suggest against using hyphenation and toward \allowbreak. I'm making a habit of inserting these at the case changes in in my camel-case method names. – greg Jan 6 '12 at 18:44
But I still don't get a "-" in the end of the line, indicating that next lines word is part of previous line! Otherwise nice. – David Everlöf May 2 '13 at 13:20

You can have a look at the packages url and path. Both have pros and cons, depending on what you want. So far, I used path and am pleased with it.

Note that the command \path{} exists even without loading the path package. From what I saw, its behaviour is more or less the same, but you cannot specify the break characters.

Finally, in addition to \allowbreak already mentioned, you can also use \- to define conditional breaks. But in that case, LaTeX will put a dash at the end of the line.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.