3

My first question here, so it may sound rambling. So far I've found the answers about preventing hyphenation across lines and for setting margins, but I'm having trouble putting it together.

This is for my dissertation which has strict formatting requirements and which is otherwise finished. A committee member told me to stop the words from splitting across the lines with the automatically-inserted hyphens, but when I use the commands to prevent it, the words often cross the 1-inch right margin. I have the file set as ragged right (which is also required in my formatting). I used a template (designated as the document class) that already had the margins and most other formatting set appropriately for my university's requirements. Unfortunately since I didn't create that file, I'm not sure what other settings have been changed from the default. Before I tried changing the hyphenation, the margins seemed perfect. But when I try preventing the hyphenation (which technically worked), this problem with the margins arose. The document is very long and going through to discover every problematic word is not feasible.

I believe this is the line in the master template .dtx file that sets the margins, which I have not changed.

\RequirePackage[letterpaper,margin=1in,includehead,nofoot]{geometry}

In my own preamble, I use a bunch of packages, including ragged2e, and in certain places include the \raggedright command where needed. (I'm including my complete list in case a conflict between them is the issue.) I'm currently setting the \righthyphenmin command =8 because that seems to be the smallest number that produces conservative hyphenation.

\documentclass[print]{nuthesis}
\usepackage{indentfirst}
\usepackage{titlesec}
\usepackage{lipsum}
\usepackage{url}
\usepackage{ctable} 
\usepackage{multirow}
\usepackage[singlelinecheck=off]{caption}
\usepackage{chngcntr}
\usepackage{graphicx}
\usepackage{placeins}
\usepackage{graphicx}
\usepackage{color}
\usepackage{multirow}
\usepackage{caption}
\usepackage{ragged2e} 
\graphicspath{{./figuresfolder/}} 
\definecolor{gray}{gray}{0.65}
\righthyphenmin=8

The template also includes these packages with the following settings, which I have not changed.

\documentclass{ltxdoc}
\usepackage{url}
\usepackage{booktabs}
\usepackage{fancyvrb}
\EnableCrossrefs         
\CodelineIndex
\RecordChanges
\newcommand{\pkg}[1]{\textsf{#1}}
\setlength{\parskip}{.5\baselineskip}
\newlength{\codeSkip} \setlength{\codeSkip}{2ex}

I have tried so many of the suggested answers and each of them produce some problem. I am not totally sure about how the template is working in conjunction with the files I've created or edited, which complicates my ability to apply the existing answers successfully. Thanks for your help.

  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – Ruben Aug 4 '15 at 20:16
  • 2
    Try using \sloppy in the preamble. It changes the parameters of the paragraph optimization which will allow larger inter-word spaces, but produce less/eliminate overfull lines. – Steven B. Segletes Aug 4 '15 at 20:28
  • 3
    a different method for absolutely suppressing hyphenation is to set \hyphenpenalty=10000 \exhyphenpenalty=10000. the first suppresses ordinary hyphenation, and the second prohibits line breaks at explicit hyphens. if un-hyphenated words now extend out into the margins, you probably need to increase the "tolerance" and allow more stretch between words; \tolerance=1000 \emergencystretch=2em should help with that. (this is stricter than latex's \sloppy setting, so should be a little tidier while still allowing additional flexibility.) – barbara beeton Aug 4 '15 at 20:28
  • I'm quite surprised about the loading of ltxdoc, which is very strange for a dissertation. Of course I'm surprised also about not allowing hyphenation: it has been a common practice in typography for some centuries in order to avoid bad lines, particularly for languages with long words. A dissertation, even in English, often uses long words. Probably the committee member is afraid that wrong hyphenation is used; this is quite rare for TeX: what language is your dissertation in? – egreg Aug 4 '15 at 21:59
  • 1
    @Carina The only sensible way to avoid hyphenation is typesetting ragged right. – egreg Aug 5 '15 at 10:52
1

hyphenation can be suppressed more directly by setting \hyphenpenalty=10000 to suppress ordinary hyphenation, and \exhyphenpenalty=10000 to prohibit line breaks at explicit hyphens.

if un-hyphenated words now extend out into the margins, you probably need to increase the "tolerance" and allow more stretch between words; \tolerance=1000 \emergencystretch=2em should help with that.

the result will still be ragged right, but less so than what results from latex's \sloppy setting. varying the values of these four parameters after viewing the output can allow quite a bit of flexibility in order to achieve an optimally pleasing result.

in a comment, the original poster reported that these values were chosen after experimentation as yielding the most satisfying result:

 \hyphenpenalty=1000
 \tolerance=500
 \emergencystretch=2.5em
  • Yes, thank you for writing the final answer. To clarify for future users, \raggedright was already employed before I asked this question. The question was about modifying the standard ragged right settings to hyphenate words less frequently with more conservative settings. I am using package {ragged2e}. – Carina Aug 7 '15 at 19:56

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.