1

In my thesis, I have a subsection title which generates an overfull \hbox in the body of the thesis, but not in the table of contents. So I would like to instruct TeX to break the line in the body, but not in the index. My try was:

\discretionary{\\}{}{}

and the response was:

enter image description here

So it doesn't work, and I'm starting to think I am misinterpreting \discretionary. Right now I am out of ideas. Is there a way to achieve the above?

PS Just hyphenating spaces won't do because it won't remove the overfull \hbox.

  • The macro \allowbreak is used to signify a permissible (but not mandatory) breakpoint. – Steven B. Segletes Nov 7 '17 at 15:26
  • @Steven That is surely a macro to keep in mind. 'Cause it just solved my problem :). Would you mind converting your comment to an answer? – MickG Nov 7 '17 at 15:28
  • 2
    the usual way is \subsection[no break]{with\\break} or actually headings are better set raggedright in which case you should not get an overfull box anyway. (You haven't supplied a test file so no tested answer) – David Carlisle Nov 7 '17 at 15:55
  • 2
    @MickG the documented latex version of \allowbreak is \linebreak[0] – David Carlisle Nov 7 '17 at 16:11
2

The macro \allowbreak provides a permissible, but not mandatory breakpoint (without hyphen). If one wants the breakpoint hyphenatable (also called an optional hyphenation), then \- should be used.

As one can see, the toc entries are all the same, even though the subsectioning title in the first case overfills the \hbox, in the second, breaks without hyphen, and in the third, breaks with hyphen.

\documentclass{report}

\begin{document}
\tableofcontents
\subsection{This is a testtesttest This is a testtesttest This tezzzzzzzz
  This is a testtesttest This is a testtesttest }

\subsection{This is a testtesttest This is a testtesttest This tezz\allowbreak zzzzzz 
  This is a testtesttest This is a testtesttest }

\subsection{This is a testtesttest This is a testtesttest This tezz\-zzzzzz 
  This is a testtesttest This is a testtesttest }

\end{document}

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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