仅为化学宏启用连字符

仅为化学宏启用连字符

我正在用 XeLaTex 写论文。由于我们的论文中不常用/不鼓励使用连字符,所以我使用该hyphenat软件包将其关闭。不幸的是,这也会阻止很长的化学名称中的换行。我还有很多很长的化学式,有时必须使用连字符,例如在标题和表格中。

有没有办法禁止对普通文本使用连字符,同时允许对chemmacroschemformula包的命令使用连字符?我的目标是在序言中定义长名称和公式的命令,以便 XeLaTex 知道如何在标题、目录、说明等中将它们断开。否则我每次都必须手动断开它们。

这是我的 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}

由于hyphenate包装发生了变化,\hyphenpenalty所以\exhyphenpenalty我也尝试了这些和一些其他值。

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

我使用它们代替hyphenate包,\sloppy并尝试了 1-10000 之间的不同值。但我只能全局禁止或允许连字符。我不介意一些断字,但只适用于非常长的单词,并且只适用于我的条件,例如 Antibiotika-resistenz-entwicklung。所以我添加了这个(我尝试了 4-75 之间的不同数字):

\righthyphenmin=75
\lefthyphenmin=75

这应该是换行符前后的字母,对吧?但是,它没有效果,我仍然在两个字母之后换行,而且是在很短的单词中。我也试过了\hyphenation{Antibiotika-resistenz-entwicklung}。但那也没用。说实话,我不鼓励使用此选项,因为这意味着我必须手动输入很多单词。那么我做错了什么?谢谢你的帮助!

答案1

不幸的是,没有人回复,我还没有找到这个问题的解决方案polyglossia。但是,我能够用 解决问题hyphsubst package。因此,我从 切换polyglossiababel。因此,如果有人对解决方案感兴趣,以下代码运行良好,并提供了我想要的行为。

\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}

相关内容