Minimize hifenizações com ragged2e

Minimize hifenizações com ragged2e

Quase todos os guias do LaTeX recomendam \RaggedRighto ragged2epacote em vez do arquivo \raggedright. Mas sempre fiquei frustrado com muitas palavras hifenizadas com \RaggedRight. Eu entendo que vou conseguir alguns (onde \raggedrightnão dá nenhum), mas recebo muitos.

Decidi comparar \RaggedRightcom justificativa completa e descobri consistentemente que obtenho mais hífens do \RaggedRightque com justificativa completa, o que não esperaria. No exemplo abaixo, obtenho apenas uma hifenização com justificativa completa (e isso apenas em um ponto de hifenização criado manualmente para resolver um overfull \hbox), mas obtenho sete com \RaggedRight. (O texto é de Moby Dick, que é de domínio público.)

Posso reduzir a hifenização obtida \RaggedRightpara que seja comparável ao que obtenho com plena justificativa?

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

Responder1

Algumas palavras sobre quebra de linha. O TeX atribui uma qualidade a cada linha, com base na quantidade de estiramento da cola nela contida. Em uma configuração irregular à direita, há apenas cola extensível à direita ( \rightskip), o que tem como consequência que essa cola (se finita) geralmente estica mais do que o indicado. O padrão para \RaggedRighttem um alongamento “ótimo” de no máximo 2 em, mas é bem provável que as linhas não consigam chegar perto da margem direita, então é esperado um alto índice de maldade. Com o padrão \hyphenpenaltyde 50, o TeX achará mais barato, para minimizar os deméritos totais, hifenizar para se aproximar da margem.

Se tornarmos a hifenização menos conveniente, o alongamento da cola terá um impacto mais leve nos deméritos totais do que a hifenização.

Observe que com a configuração padrão \raggedright, a hifenização nunca acontecerá (bem, dificilmente nunca), porque \rightskippossui alongamento infinito ( 0pt plus 1fil), então as linhas terão zero de maldade e os deméritos serão adicionados apenas a partir de \linepenalty, então o TeX apenas minimizará o número de linhas.

Encontrar um bom compromisso não é fácil: aumentar o alongamento \rightskippode tornar o TeX mais disposto a definir linhas mais curtas. Proponho aumentar o \hyphenpenalty, em vez disso, e microtypeisso geralmente tem um impacto muito bom na configuração do parágrafo.

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

insira a descrição da imagem aqui

Resultado: com a penalidade de hifenização padrão, três palavras são hifenizadas; com o aumento da penalidade de hifenização, apenas um.

O mesmo semmicrotype

insira a descrição da imagem aqui

Resultado: com a penalidade de hifenização padrão, sete palavras são hifenizadas; com o aumento da penalidade de hifenização, apenas dois.

Em todos os casos, o hífen preciselyé inevitável, por causa do travessão.

Responder2

A "irregularidade" de \RaggedRightpode ser configurada por length \RaggedRightRightskip, que é inserido na extremidade direita de uma linha, quando o TeX quebra o parágrafo. O padrão é 0pt plus 2em, o que significa que a linha pode ser completa ou curta, com até 2em de espaço em branco no lado direito.

Aumentar o valor para 2.8emreduz o número de hifenizações para um, ao custo de um lado direito do parágrafo mais irregular.

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

Resultado

informação relacionada