窄列更聰明的連字符?

窄列更聰明的連字符?

我知道如何通過\nohyphens{.....}(來自連字符)。但我真正想要的是巧妙地連字符。希望透過以下範例可以清楚地闡明我的意思。

左側是表中某列的一段文本,使用該\nohyphens{...}指令呈現。這留下了很多開放的空白區域。右側是由 vanilla XeLaTeX 排版的相同文字。正如你所看到的,它仍然在文本中間留下一個大的空白,並且它還引入了相當奇怪的連字符“or-phaning”,而不是例如更自然的“更正”。
根本沒有連字符 預設行為

這是我在原始程式碼中引入“更正”而製作的更聰明的版本:

有些是手工調整的

至少在我看來,這似乎比上述任何一個版本都要好得多。

所以基本問題是:我能否讓 LaTeX 自動為我執行此操作,例如指定最長可接受的詞間空格?

聚苯乙烯。另一個更複雜的解決方案是為表中的列指定“目標寬度”,例如,.25\textwidth然後讓系統優化以生成一個表,使我盡可能接近指定的空白分數和表寬度,同時最小化帶連字符的單字數...但我不知道LaTeX 是否可以在多個變數中進行這種動態優化!這是最後一張圖片,我通過轉到列來完全擺脫了連字符.27\textwidth。這似乎是迄今為止最具可讀性的版本。

在此輸入影像描述

答案1

當嘗試以非常窄的尺寸排版文字時,有時最好(最不壞?!)使用該\sloppy指令,如下例所示。

在這種情況下設定 也很有幫助\righthyphenmin2。 (對於英語文本,此參數的預設值為3。)

在此輸入影像描述

\documentclass[12pt,letterpaper]{article}
\usepackage[showframe,margin=3.38in]{geometry} 
  % \textwidth = 8.5"-2*3.38" = 1.74"
\frenchspacing
\righthyphenmin2
\sloppy
\usepackage{fontspec}
\setmainfont[Ligatures=TeX]{Linux Libertine O}
\begin{document}
\noindent
Quality control is handled with corrections and the ``orphaning'' mechanism in case 
of nonresponsive authors. Some articles are world-writeable, as in the wiki model.
\end{document}

答案2

我不確定你為什麼使用\nohyphens我認為你想要更多而不是更少。使用連結表,因為您沒有為問題中的範例提供程式碼,我得到的結果還不錯,儘管顯然可以進行更多調整。

在此輸入影像描述

\documentclass[article,a4paper,12pt,twoside]{memoir}

\usepackage{hyphenat}

\setlrmarginsandblock{40mm}{20mm}{*}
\setulmarginsandblock{20mm}{20mm}{*}

\begin{document}

\renewcommand{\arraystretch}{1.5}
\begin{table}
\begin{center}
\raisebox{3in}{\small
\begin{tabular}{|*{3}{>{\hyphenpenalty0 }p{.25\textwidth}|}}
\hline
% \multicolumn{1}{p{.25\textwidth}}{\textbf{Relevance}}
\begin{center}(PM)
\end{center}

Ultimately relevance depends on peer review, and irrelevant content
may be deleted. Mechanisms to ensure that relevant content
\emph{will} be added could be improved. &
\begin{center}(WP)
\end{center}
People contribute articles about what
they're interested in; apart from this, rules like WP:WEIGHT come into
play.&
\begin{center}(DO)
\end{center}

Anyone can upload projects (for ``full projects'', one time approval
is needed), but getting changes into the core requires considerably
more vetting. \\
%\multicolumn{1}{p{.25\textwidth}}{\textbf{Quality}}
Quality control is handled with corrections and the ``orphaning'' mechanism
in case of nonresponsive authors. Some articles are world-writeable,
as in the wiki model. & Automated tools for spam and vandalism detection
combined with a system of editorial oversight, in which Jimmy Wales
has last say. & In addition to bug reports and feature requests handled
through the issue tracker, modules can make use of an automated patch
testing system.\\
%\multicolumn{1}{p{.25\textwidth}}{\textbf{Scalability}}
Peer review is distributed. Links are handled automatically. Caching
is deployed where relevant; in particular, interlinking features are
kept up to date. & The database and other infrastructure is massively
scaled. There are many bots that help with small tasks. & In theory,
anyone can join. Earl Miles, NYCCamp 2012 keynote: ``\emph{There are
no insiders, except Dries; there are no outsiders, only resumes.}''
\\
% \multicolumn{1}{p{.25\textwidth}}{\textbf{Consistency}}
Although automatic links and corrections can help with consistency,
mainly PM relies on standards for proof and expository quality.
&NPOV is the key rule, which works together with templates and other
process tools to maintain community standards about style and
content. & The project issue queues are the place to go when one
module's changes breaks another's. The core of the project has
considerable oversight in these
matters.\\
% \multicolumn{1}{p{.25\textwidth}}{\textbf{Motivation}}
People are solving some of their learning, exposition, and social
needs on the site by writing and reviewing articles and posting in the
forums.& As of 2006, over 50\% of the site had been written by less
than 1\% of the users; these days, paid editing is somewhat
notorious.& Miles continued: ``\emph{To build a resume, find someone
who needs help, and help them. Find something that needs doing, do
it.}'' \\ \hline
\end{tabular}
}
\end{center}
\caption{As typeset ``out of the box''}
\end{table}


\end{document}

如果您在右邊距上允許一點靈活性,並添加微類型,您將得到:

\usepackage{microtype}

...

\begin{tabular}{|*{3}{
   >{\hyphenpenalty0 \rightskip0pt plus .3em \emergencystretch2em}%
   p{.25\textwidth}|}}

在此輸入影像描述

相關內容