我正在尝试获取一个表格,其中三列文本垂直对齐在顶部(使用数组包和 p{'width'}),但我不知道如何获得单词之间的规则间距,就像一个对齐的段落,其中长单词有正确的连字符。
\documentclass[a4paper, onehalfspacing, 12pt]{article}
\usepackage[top=25mm,bottom=30mm,left=30mm,right=30mm]{geometry}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures={TeX, NoCommon}}
\setmainfont{pala.ttf}
\usepackage{array}
\usepackage{polyglossia}
\setmainlanguage{english}
\usepackage{setspace}
\begin{document}
\begin{tabular}{|p{3cm}|p{3cm}|p{3cm}|}
\hline
But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. &No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. & Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. \\
\hline
\end{tabular}
\end{document}
谢谢。
答案1
您可以加载软件包ragged2e
并array
使用类似 进行测试>{\RaggedRight\justifying}p{3cm}
。但最简单的解决方案就是:\usepackage{microtype}
。
编辑:这两种解决方案似乎都不适用于 XETEX。
看看这个例子:
\documentclass[a4paper, onehalfspacing, 12pt, english]{article}
\usepackage[top=25mm,bottom=30mm,left=30mm,right=30mm]{geometry}
\usepackage{babel, ragged2e, array}
\usepackage[factor=3500, stretch=40]{microtype}
% \defaultfontfeatures{Ligatures={TeX, NoCommon}}
% \setmainfont{pala.ttf}
\usepackage{array}
% \usepackage{polyglossia}
% \setmainlanguage{english}
\usepackage{setspace}
\begin{document}
\begin{tabular}{|>{\RaggedRight\justifying}p{3cm}|>{\RaggedRight\justifying}p{3cm}|>{\RaggedRight\justifying}p{3cm}|}
\hline
But I must explain to you how all this mistaken idea of denouncing
pleasure and praising pain was born and I will give you a complete
account of the system, and expound the actual teachings of the great
explorer of the truth, the master-builder of human happiness. &No one
rejects, dislikes, or avoids pleasure itself, because it is pleasure,
but because those who do not know how to pursue pleasure rationally
encounter consequences that are extremely painful. & Nor again is
there anyone who loves or pursues or desires to obtain pain of itself,
because it is pain, but because occasionally circumstances occur in
which toil and pain can procure him some great pleasure.\\ %\arraybackslash
\end{tabular}
\end{document}
呈现为:
嗯,不是很有说服力,也许可以玩一下局部微类型值,但这并不是很好。
答案2
您必须放弃一些东西,如果您想保持对齐和空白控制,您需要放弃其他东西。这放弃了通常的连字规则:仍然存在一些间隙,但请尝试使用最终的字体选择,您随时可以添加更多连字条目。
\documentclass[a4paper, onehalfspacing, 12pt]{article}
\usepackage[top=25mm,bottom=30mm,left=30mm,right=30mm]{geometry}
%\usepackage{fontspec}
%\defaultfontfeatures{Ligatures={TeX, NoCommon}}
%\setmainfont{pala.ttf}
\usepackage{array}
%\usepackage{polyglossia}\setmainlanguage{english}
\lefthyphenmin1
\righthyphenmin1
\hyphenation{ mis-tak-en tea-ch-ings buil-der co-m-pl-ete
hu-m-an hap-pi-n-ess av-oid-s en-c-oun-ter con-se-qu-en-ces
ex-tr-eme-ly pain-ful a-nd pai-n pr-ai-s-ing
pur-s-ues be-c-au-se cir-cum-st-an-ces
pl-ea-s-ure oc-c-ur wh-ich t-oil
cir-c-um-st-an-c-es h-im th-ere
}
\usepackage{setspace}
\showhyphens{
But I must explain to you how all this mistaken idea of denouncing pleasure and
praising pain was born and I will give you a complete account of the system, and
expound the actual teachings of the great explorer of the truth, the
master builder of human happiness}
\showhyphens{
No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but
because those who do not know how to pursue pleasure rationally encounter
consequences that are extremely painful
}
\showhyphens{
Nor again is there anyone who loves or pursues or desires to obtain pain of
itself, because it is pain, but because occasionally circumstances occur in which
toil and pain can procure him some great pleasure
}
\begin{document}
\begin{tabular}{|*3{>{\spaceskip .3em plus .1em minus .15em
\xspaceskip.4em plus .1em minus .2em\relax
}p{3cm}|}}
\hline
But I must explain to you how all this mistaken idea of denouncing pleasure and
praising pain was born and I will give you a complete account of the system, and
expound the actual teachings of the great explorer of the truth, the
master-\hspace{0pt}builder of human happiness. &
No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but
because those who do not know how to pursue pleasure rationally encounter
consequences that are extremely painful. &
Nor again is there anyone who loves or pursues or desires to obtain pain of
itself, because it is pain, but because occasionally circumstances occur in which
toil and pain can procure him some great pleasure. \\
\hline
\end{tabular}
\end{document}