ragged2e でハイフネーションを最小限に抑える

ragged2e でハイフネーションを最小限に抑える

LaTeX のほぼすべてのガイドでは、組み込みの よりもパッケージ\RaggedRightのを推奨しています。しかし、 を使用したハイフンでつながれた単語が多すぎることにいつもイライラしています。 では何も返されないため、ある程度は返されることは理解していますが、多すぎます。ragged2e\raggedright\RaggedRight\raggedright

完全両端揃えと比較してみることにしました\RaggedRightが、 のほうが一貫して、 よりもハイフンが多くなることがわかりました\RaggedRight。これは予想外のことです。以下の例では、完全両端揃えではハイフンが 1 つしか生成されません (これは を解決するために手動で作成されたハイフン ポイントでのみ生成されますoverfull \hbox) が、 では 7 つ生成されます\RaggedRight。(テキストはパブリック ドメインの Moby Dick からの引用です。)

\RaggedRight完全な両端揃えで得られるものと同等になるように、ハイフネーションを減らすことはできますか?

\documentclass{article}
\usepackage[textwidth=4.0in]{geometry}
\usepackage{ragged2e}

% 1 hyphenated word with no ragged right
% 7 hyphenated words with \RaggedRight from ragged2e

\begin{document}
\RaggedRight
Call me Ishmael. Some years ago---never mind how long
precise\-ly---having little or no money in my purse, and nothing
particular to interest me on shore, I thought I would sail about a
little and see the watery part of the world. It is a way I have of
driving off the spleen and regulating the circulation. Whenever I
find myself growing grim about the mouth; whenever it is a damp,
drizzly November in my soul; whenever I find myself involuntarily
pausing before coffin warehouses, and bringing up the rear of
every funeral I meet; and especially whenever my hypos get such an
upper hand of me, that it requires a strong moral principle to
prevent me from deliberately stepping into the street, and
methodically knocking people's hats off---then, I account it high
time to get to sea as soon as I can. This is my substitute for
pistol and ball. With a philosophical flourish Cato throws himself
upon his sword; I quietly take to the ship. There is nothing
surprising in this. If they but knew it, almost all men in their
degree, some time or other, cherish very nearly the same feelings
towards the ocean with me.
\end{document}

答え1

改行について少し説明します。TeX は、行内のグルーの伸張量に基づいて、各行に不良度を割り当てます。右寄せ設定では、右側 ( \rightskip) にのみ伸張可能なグルーがあるため、このグルー (有限の場合) は通常、指定された以上に伸張します。 の既定値は\RaggedRight最大 2 em の「最適な」伸張ですが、右マージンの近くでは行がこの値に到達できない可能性が高いため、不良度が高くなることが予想されます。既定値\hyphenpenaltyの 50 では、TeX は、総デメリットを最小限に抑えるために、マージンに近づくようにハイフネーションする方が安価であると判断するでしょう。

ハイフネーションの利便性を低下させると、グルーストレッチはハイフネーションよりも全体的なデメリットに与える影響が小さくなります。

標準設定では、は無限に伸びる\raggedrightため ( )、ハイフネーションは決して行われません (まあ、ほとんど行われません)。そのため、行の悪影響はゼロになり、デメリットは からのみ追加されます。そのため、TeX は行数を最小化するだけです。\rightskip0pt plus 1fil\linepenalty

適切な妥協点を見つけるのは簡単ではありません。 の伸縮を増やすと、\rightskipTeX がより短い行を設定する可能性が高くなります。\hyphenpenalty代わりに、と を増やすことを提案しますmicrotype。これは通常、段落設定にかなり良い影響を与えます。

\documentclass{article}
\usepackage[textwidth=4.0in]{geometry}
\usepackage{microtype}
\usepackage{ragged2e}

\begin{document}
\newcommand\incipit{Call me Ishmael. Some years ago---never mind how long
precise\-ly---having little or no money in my purse, and nothing
particular to interest me on shore, I thought I would sail about a
little and see the watery part of the world. It is a way I have of
driving off the spleen and regulating the circulation. Whenever I
find myself growing grim about the mouth; whenever it is a damp,
drizzly November in my soul; whenever I find myself involuntarily
pausing before coffin warehouses, and bringing up the rear of
every funeral I meet; and especially whenever my hypos get such an
upper hand of me, that it requires a strong moral principle to
prevent me from deliberately stepping into the street, and
methodically knocking people's hats off---then, I account it high
time to get to sea as soon as I can. This is my substitute for
pistol and ball. With a philosophical flourish Cato throws himself
upon his sword; I quietly take to the ship. There is nothing
surprising in this. If they but knew it, almost all men in their
degree, some time or other, cherish very nearly the same feelings
towards the ocean with me.}

\RaggedRight

\noindent With \texttt{microtype}

\bigskip

\noindent\texttt{\string\hyphenpenalty=50}

\incipit

\bigskip

\noindent\texttt{\string\hyphenpenalty=500}

\hyphenpenalty=500

\incipit

\end{document}

ここに画像の説明を入力してください

結果: デフォルトのハイフネーション ペナルティでは 3 つの単語がハイフンで区切られますが、ハイフネーション ペナルティを増やすと 1 つの単語だけがハイフンで区切られます。

同じmicrotype

ここに画像の説明を入力してください

結果: デフォルトのハイフネーション ペナルティでは 7 つの単語がハイフンで区切られますが、ハイフネーション ペナルティを増やすと 2 つの単語だけがハイフンで区切られます。

preciselyいずれの場合も、 em-dash があるため、ハイフンは避けられません。

答え2

の「不規則さ」は、TeX が段落を分割するときに行の右端に挿入される\RaggedRight長さ によって設定できます。デフォルトは で、行がいっぱいになることも、右側に最大 2em の空白を付けて短くなることもあります。\RaggedRightRightskip0pt plus 2em

値を大きくすると、2.8emハイフネーションの数が 1 つに減りますが、段落の右側がより不揃いになります。

\documentclass{article}
\usepackage[textwidth=4.0in]{geometry}
\usepackage{ragged2e}

\setlength{\RaggedRightRightskip}{0pt plus 2.8em}

\begin{document}
\RaggedRight
Call me Ishmael. Some years ago---never mind how long
precise\-ly---having little or no money in my purse, and nothing
particular to interest me on shore, I thought I would sail about a
little and see the watery part of the world. It is a way I have of
driving off the spleen and regulating the circulation. Whenever I
find myself growing grim about the mouth; whenever it is a damp,
drizzly November in my soul; whenever I find myself involuntarily
pausing before coffin warehouses, and bringing up the rear of
every funeral I meet; and especially whenever my hypos get such an
upper hand of me, that it requires a strong moral principle to
prevent me from deliberately stepping into the street, and
methodically knocking people's hats off---then, I account it high
time to get to sea as soon as I can. This is my substitute for
pistol and ball. With a philosophical flourish Cato throws himself
upon his sword; I quietly take to the ship. There is nothing
surprising in this. If they but knew it, almost all men in their
degree, some time or other, cherish very nearly the same feelings
towards the ocean with me.
\end{document}

結果

関連情報