I had a long section heading that the last word will hyphenate at the end, which goes into the margin.
Minimal working example:
\documentclass{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\begin{document}
\subsection{longlonglong wordswordswordwords that will cause problem}
\blindtext
\end{document}
produces:
I don't want the problem be hyphenated and want it to break line before the last word. I tried three ways:
Manullly add
\\. This produces the desired output but it's dirty and bad: the pdf bookmark do not recognize\\, the heading may fit into TOC but it just breaks, I may want to switch to double column or other document class.I tried the solutions in this question. That is, using
nohyphensprovided byhyphenatpackage, but things gets worse:
use penalty for hyphen:
\subsection{ \begingroup \hyphenpenalty 10000 \exhyphenpenalty 10000 longlonglong wordswordswordwords that will cause problem \endgroup }
result:
Yeah it breaks at the last word but the first line becomes right-justified. I want them to be left-justified (and it should).
Hope some want can show me some workaround. Thanks in advance!
