3

I am writing my thesis with XeLaTex. Since hyphenation is uncommon/discouraged in our theses I switched it off by using the hyphenat package. Unfortunately, this also prevents line breaks in very long chemical names. I also have a lot very long chemical formulas which sometimes have to be hyphenated, e.g. in headings and tables.

Is there a way to disallow hyphenation for normal text and at the same time allow hyphenation for commands of the chemmacros and chemformula packages? My aim is to define commands for long names and formulas in the preamble so that XeLaTex knows how to break them in headings, TOC, captions etc. Otherwise I would have to break them manually everytime.

This is my MWE:

\documentclass[%
     headsepline,
     footsepline,
     twoside,       
     numbers=noenddot,
     12 pt]{scrbook}
\usepackage[a4paper]{geometry}%
\usepackage{fontspec}
\setmainfont[Ligatures=TeX]{Cambria}
\usepackage{polyglossia}    
\setmainlanguage[spelling=new]{german}
\usepackage{microtype}
\usepackage[none]{hyphenat}%
\usepackage{chemmacros}
\chemsetup{language = german,
     formula = chemformula,     
     greek = textgreek,
     modules = all,
     }
\NewChemCompoundProperty{|}{\-}% discretionary hyphens in chemformula

\begin{document}
\sloppy

These are filling words for a sentence with the very long word Antibiotikaresistenzentwicklung which I don't want to hyphenate.

This is a long chemical name \iupac{Tetra|cyclo[2.2.2.1^{1,4}]|undekan-2-dodekyl-5\-(hepta|dekyl|iso|dodekyl|thio|ester)} which I would like to break over several lines at one of the marked positions.

This is another sentence with the long chemical formula \ch{Cu(NCMe)2|(pyz)|[AuCl2(CN)2]2|UO2(NO3)2} which I would also like to break at one of the marked positions.

\end{document}

Since the hyphenate package changes \hyphenpenalty and \exhyphenpenalty, I also played with these and some other values.

\tolerance=9999
\hyphenpenalty=9000
\exhyphenpenalty=9999
\hbadness=10000
\emergencystretch=\maxdimen

I used them instead of hyphenate package and \sloppy and tried different values from 1-10000. But I only managed to globally disallow or allow hyphenation. I would not mind a few breaks but only for very long words and only to my conditions like e.g. Antibiotika-resistenz-entwicklung. So I added this (I tried with varying number from 4-75):

\righthyphenmin=75
\lefthyphenmin=75

This should be the letters before and after a break, right? But however, it has no effect and I still get line breaks after only two letters and in very short words. I also tried \hyphenation{Antibiotika-resistenz-entwicklung}. But that didn't work either. And to be honest, I am discouraged to use this option because that would mean I had to enter a lot of words manually. So what am I doing wrong? Thank you for your help!

0

Unfortunately, nobody replied and I haven't found a solution of this issue for polyglossia yet. But, however, I was able to solve the problem with the hyphsubst package. Hence, I switched from polyglossia to babel. So if anyone is interessested in a solution, the following code works nicely and gives exactly the behavior I want.

\documentclass[%
   headsepline,
   footsepline,
   twoside,       
   numbers=noenddot,
   12 pt]{scrbook}
\usepackage[a4paper]{geometry}%
\usepackage{fontspec}
\setmainfont{Cambria}
\makeatletter\chardef\l@nohyphenation=255 \makeatother
\usepackage[ngerman=nohyphenation]{hyphsubst}
\usepackage[ngerman]{babel}
\usepackage{microtype}
\usepackage{chemmacros}
\chemsetup{language = german,
   formula = chemformula,     
   greek = textgreek,
   modules = all,
}
\NewChemCompoundProperty{|}{\-}% discretionary hyphens in chemformula

\begin{document}
\sloppy

These are filling words for a sentence with the very long word Antibiotikaresistenzentwicklung which I don't want to hyphenate.

This is a long chemical name \iupac{Tetra|cyclo[2.2.2.1^{1,4}]|undekan-2-dodekyl-5\-(hepta|dekyl|iso|dodekyl|thio|ester)} which I would like to break over several lines at one of the marked positions.

This is another sentence with the long chemical formula \ch{Cu(NCMe)2|(pyz)|[AuCl2(CN)2]2|UO2(NO3)2} which I would also like to break at one of the marked positions.

\end{document}

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.