1

Sometimes, when using the hyphenat package to prevent hypenation in sentences, the following undesirable aesthetic occurs, as illustrated in the first paragraph of the output of this MWE:

\documentclass{book}
\usepackage[none]{hyphenat} % To prevent hyphenation

\begin{document} \large A paragraph with sentences comprised of some-long-words. A paragraph with sentences comprised of some-long-words. A paragraph with sentences comprised of some-long-words. The same paragraph with sentences comprised of some-long-words. \vskip 10pt A paragraph with sentences comprised of some-long-words. A paragraph with sentences comprised of some-long-words. A \ paragraph with sentences comprised of some-long-words. The same paragraph with sentences comprised of some-long-words. \end{document}

enter image description here

In order to force the paragraph to ``look better'', I make use of \\ in the second paragraph; but as you can see, the justification of the second line is affected. (The same thing happens when one uses, for example, \newline as well)

I know that I can force the desired justification by a series of hfills, but I am wondering is there an automatic way to preserve the justification of all sentences when trying to prevent the described undesirable aesthetic---as it can happen fairly often when typesetting large documents?

More specifically,

QUESTION: When using hypenat and trying to correct an overrun of words in a given sentence with \\ (or the like), how may the desired justification of the said sentence be automatically be preserved? (I know word \hfill word \hfill word \hfill etc. would work, but since the problem can occur many times, I would like, if possible, to apply \\ (or something similar) each time, and not have to deal with the \hfills to accomplish this.)

Thank you.

DDS
  • 8,816
  • 4
  • 9
  • 36
  • 4
    well the price for suppressing hyphenation is that justifying doesn't work without "undesirable aesthetic". What ever you do, something will look bad. So if you don't want hyphenation then don't justify the text, use \raggedright instead. – Ulrike Fischer Aug 05 '21 at 14:18
  • @Ulrike Fischer I have just revised the question to make what I would like to do more clear. Yes, the ``undesirable aesthetic'' seems unfortunately to be the price of using hyphenat. Thank you for your comment. – DDS Aug 05 '21 at 14:48
  • 1
    use \linebreak or (generally) \sloppy. (it does what the work says. That is bad typography). – Ulrike Fischer Aug 05 '21 at 14:51
  • Why would you want to suppress hyphenation to begin with? – egreg Aug 05 '21 at 16:59
  • @Ulrike Fischer Actually---not bad at all when I use it one of my real paragraphs. Perhaps you will consider posting your comment in the form of an answer. Many thanks. – DDS Aug 05 '21 at 16:59
  • @egreg When overrunning sentences do not occur and the width of the paragraph is long enough, I think it looks better. But sometimes I display text in tcolorboxes or tikzpictures---and too many hyphenations can be distracting. So, I may unhyphenate to see if the appearance can be improved that way. – DDS Aug 05 '21 at 17:03
  • @mlchristians TeX is usually quite frugal in hyphenation when the line width is generous. – egreg Aug 05 '21 at 17:32
  • @egreg Indeed, perhaps, in mathematical papers or longer similar publications such as textbooks, but when typesetting a non-mathematical book, I have found it hypenation occurs often enough (which is not unusual). With the question I asked, I wanted to see if there is something that can be done about it without resorting to an inordinate amount of work (e.g. hfills) which can cause other problems should I later unwaringly copy some of the text into other documents. – DDS Aug 05 '21 at 17:48
  • 1
    You can set \emergencystretch to increase the space TeX will allow between words in difficult paragraphs, and the microtype package will allow font expansion in place of long interword spaces. – Davislor Aug 05 '21 at 18:05
  • @Davislor Many thanks. I did not know that. Must \emergencystretch be used in conjunction with the microtype package? Also, does the microtype package invoked by itself potentially offer an improvement in the typesetting? – DDS Aug 05 '21 at 18:30
  • Although the intent of this question was to avoid bad line-breaking in the presence of urls, the tactics described in the answers should provide a usable approach for you: How to avoid using \sloppy document-wide to fix overfull \hbox problems? (Potential duplicate.) – barbara beeton Aug 05 '21 at 19:01
  • @mlchristians -- \hfill is almost always the wrong approach. The only legitimate use I see for it is if the left portion of the line is to be left justified, and the right portion flush right, with an obvious gap between, such as a "signature" on an epigraph. – barbara beeton Aug 05 '21 at 19:06
  • use of \\ explicitly prevents justification and leaves the line short. also use of the primitive \vskip seems strange in a latex document. Since you are preventing hyphenation you should probably use \sloppy you will need the extra white space to make up for the lack of hyphenation. – David Carlisle Aug 05 '21 at 20:27
  • @mlchristians No ,you can use either one separately. The \emergencystretch command is part of the LaTeX3 kernel. The microtype package is an entirely separate thing that might also help. – Davislor Aug 05 '21 at 20:50
  • @Davislor It seems that the use of microtype alone takes care at least the paragraph in question as I just found out by trying that approach to David Carlisle's just-posted solution. Thank you for pointing out the \emergencystretch approach earlier. I hope to investigate it further. – DDS Aug 05 '21 at 20:54

1 Answers1

2

If you disable hyphenation then you will struggle to get reasonable typographic output, but you can use \sloppy to allow more white space and microtype to make character adjustments to try to comprnsate,

enter image description here

\documentclass{book}
\usepackage[none]{hyphenat} % To prevent hyphenation
\usepackage{microtype}% try to repair the damage done by the above
\begin{document}
\large\sloppy
A paragraph with sentences comprised of some-long-words. A paragraph with sentences comprised of some-long-words. A paragraph with sentences comprised of some-long-words. The same paragraph with sentences comprised of some-long-words.

\end{document}

David Carlisle
  • 757,742
  • Ah! It seems to do the job nicely in one fell swoop. As an aside, for the particular paragraph given , it would appear that the microtype package is taking care of the problem itself---as removing \sloppy gives produces the same display. Moreover, it is interesting to note that replacing \sloppy by \linebreak (which I attempted here because of an earlier comment made by U. Fischer) does not work at all. So, I shall presume based on your answer that the use of microtype and \sloppy provides a general solution. Thank you for posting this answer. – DDS Aug 05 '21 at 20:49
  • @mlchristians \linebreak is a command to use at the point you want to break (like \\) not a declaration like \sloppy that affects all following paragraphs, so it does work but you need to apply it where needed. Anyway microtype can always be recommended is it avoids the problems most of the time without any additional help. – Frank Mittelbach Aug 06 '21 at 07:58