GeneralForcing LaTeX to behave M$ Word-like regarding line breaks

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
rimas
Posts: 3
Joined: Tue Oct 11, 2011 10:56 am

Forcing LaTeX to behave M$ Word-like regarding line breaks

Post by rimas »

Hello!
I found latex to be very strict about spaces between words.
I have part of the text in my thesis with technical information and hbox overfulls occurs all the time (the text is really problematic to hyphenate correctly even manually).
I tried to solve the problem by inserting \libenreak[x] commands here and there and it works great (I've checked also optional "demand" parameter and got response only on highest value - 4).
However it is not very convenient at new linebreaks usually generate new hbox overfulls :(
So the question is: is it possible to force latex to brake lines where it is possible, avoiding hbox overfulls in the part of document? (some environment?..)
Last edited by rimas on Wed Oct 12, 2011 8:03 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Forcing LaTeX to behave M$ Word-like regarding line breaks

Post by localghost »

The hyphenation algorithm of (La)TeX is the best you can get. Something is going wrong in your document or you forgot specific settings. Note that correct hyphenation depends on your language and the corresponding settings. Submit a minimal example that clearly reproduces the described behaviour. Shouldn't be difficult with "overfull hboxes all he time".


Best regards and welcome to the board
Thorsten
Montag
Posts: 340
Joined: Wed Jul 15, 2009 9:25 am

Forcing LaTeX to behave M$ Word-like regarding line breaks

Post by Montag »

rimas wrote:Hello!
I found latex to be very strict about spaces between words.
I have part of the text in my thesis with technical information and hbox overfulls occurs all the time (the text is really problematic to hyphenate correctly even manually).
Hi, I occasionally forget that -- after I copied my usual LaTeX - template-like files into my new working folder -- the wrong language is set, meaning after a couple of minutes I realize I still need to change the package/s. Maybe this helps you? :)
OS: Win 7 64-bit LaTeX: MikTeX 2.9 64-bit Editor: TXC 1 RC1
rimas
Posts: 3
Joined: Tue Oct 11, 2011 10:56 am

Forcing LaTeX to behave M$ Word-like regarding line breaks

Post by rimas »

Thanks for fast replies and suggestions. I'm writing in English so there are default settings for hyphenation. In the normal text everything is OK, but I have one section in my work which consists entirely of chemical procedures, full of chemical names, formulas, numbers with units etc.
Here is an example:

Code: Select all

\documentclass[12pt,twoside,BCOR=10mm,headsepline]{scrreprt}
\usepackage[version=3]{mhchem}
\usepackage{upgreek}
\newcommand{\nrzw}[1]{\textbf{#1}}
\newcommand{\krs}[1]{\textit{#1}}
\newcommand{\nzw}[1]{\textbf{#1}}
\newcommand{\dgrc}[1]{${#1}\,^{\circ}\mathrm{C}$}
\newcommand{\jto}[1]{\textit{J}\,=\,#1\,Hz, }
\newcommand{\sygnal}[5]{#1 (#2, #3, #4#5)}
\newcommand{\hnmr}[4]{$^1$H~NMR (#1\,MHz, #2, #3$\updelta$):#4}
\newcommand{\uvis}[2]{UV-vis (#1): $\uplambda_{\text{max}}$, nm ($\upvarepsilon \times 10^{-3}$) #2}
\newcommand{\ms}[5]{MS{#1} (\krs{m/z}): #2 calcd for \ce{#3}, #4; found, #5}
\begin{document}
\nzw{5,8-Dibromo-naphtho[2,3-\krs{c}]furan-1,3-dione (\nrzw{RV486}).} The suspension of 2,3-naph\-tha\-le\-ne\-di\-carboxylic anhydride (1.65\,g, 8.3\,mmol) and iodine (60\,mg, 0.23\,mmol) in 10\,mL of water was heated to 50--\dgrc{60} and bromine (4.84\,g, 30.3\,mmol) was added dropwise while stirring. The temperature was increased and the reaction was stirred at gentle reflux for 3\,h. After cooling to rt, the reaction mixture was poured in ice, precipitate was filtered off, washed with water and dried. The yield at this point was 92\% and recrystallization from methanol afforded pure sample of diacid with mp 220--\dgrc{1} (lit.\cite{matsuoka1971} 217-\dgrc{20}).

Anhydride function can be recovered in essentially quantitative yield by refluxing diacid in excess of acetic anhydride for 2\,h. After solvent removal and drying under vacuum, crude product was used without further purification.
\hnmr{600}{\ce{CDCl3}}{TMS, }{
        \sygnal{$(-4)\text{--}(-1.5)$}{3H}{br s}{}{NH},
        \sygnal{7.87}{2H}{s}{}{naphth.},
        \sygnal{7.96}{2H}{m}{}{\ce{C6H4}},
        \sygnal{8.30}{1H}{br s}{}{\ce{C6H4}},
        \sygnal{8.41}{1H}{br s}{\jto{4.5}}{\ce{C6H4}},
        \sygnal{8.57}{2H}{br s}{\jto{4.5}}{$\beta$-CH},
        \sygnal{8.77}{2H}{br s}{}{$\beta$-CH},
        \sygnal{8.96}{4H}{m}{}{$\beta$-CH+naphth.},
        \sygnal{9.12}{2H}{br s}{}{$\beta$-CH}}; \\
\ms{--FD}{[M]$^{{+}\cdot}$}
{C49H19{}^{79}Br^{81}BrF10N5O2}
{1058.97}
{1058.93};
\uvis{DCM}{269 (53,8), 411 (140.1), 562 (21.4), 612 (12.1)}. 
\end{document}
in this section I would like to force latex to take care only about straight text edges, even by sacrificing lines' good-looking.
rimas
Posts: 3
Joined: Tue Oct 11, 2011 10:56 am

Forcing LaTeX to behave M$ Word-like regarding line breaks

Post by rimas »

Hurrah! :)
I found the solution.
There are probably some internal parameters which control inter-word spacing, its minimum and maximum values, and I didn't found them.
But in my case the solution was to use \sloppypar{} environment. None of hbox overfull through the whole section! Perfect! :)
localghost, Montag, thanks for directing me to the solution.

P.S. it would be nice if someone will add information about LaTeX parameters responsible for inter-word spacing (the range of values to which it can be stretched or squeezed)

PPS for further reading: some interesting thoughts on a topic by Martin J. Osborne, and an extensive article about spacing in general
Post Reply