考虑一下代码
\documentclass{book}
\usepackage{xcolor}
%\usepackage[none]{hyphenat} % To prevent hyphenation within entire document.
\begin{document}
\thispagestyle{empty}
\Large
\begin{minipage}{5in}\leftskip\fill\rightskip-\leftskip\parfillskip\stretch{2}%
\textbf{{\color{red}{Einstein on Simplicity:}} ``Out of Complexity, Find Simplicity.'' ``Everything Should be Made as Simple as Possible, but Not Simpler.'' ``If You Can't Explain It Simply, You Don't Understand It Well Enough.''}
\end{minipage}
\end{document}
输出结果如下:
总的来说,我希望防止在这样的小页面中使用连字符。
我知道如果我\usepackage[none]{hyphenat}
在序言中使用连字符,我将阻止在整个文档中使用连字符---这是我不想做的。
对于 MWE 来说,\linebreak
在“made as”之后立即插入应该可以工作;然而,这种“修复”可能会在小页面的某个较早的地方强加连字符。
问题:如何才能仅在小页面中防止连字,但在文档的其他地方却允许连字?
谢谢。
答案1
对于短段落我使用
\tolerance=1
\emergencystretch=\maxdimen
\hyphenpenalty=10000
\hbadness=10000
\documentclass{book}
\usepackage{xcolor}
%\usepackage[none]{hyphenat} % To prevent hyphenation within entire document.
\begin{document}
\thispagestyle{empty}
\Large
\begin{minipage}{5in}\leftskip\fill\rightskip-\leftskip\parfillskip\stretch{2}%
\tolerance=1
\emergencystretch=\maxdimen
\hyphenpenalty=10000
\hbadness=10000
\textbf{{\color{red}{Einstein on Simplicity:}} ``Out of Complexity, Find Simplicity.'' ``Everything Should be Made as Simple as Possible, but Not Simpler.'' ``If You Can't Explain It Simply, You Don't Understand It Well Enough.''}
\end{minipage}
\end{document}
答案2
您确实想为这种类型的对象创建一个环境。
\documentclass{article}
\usepackage{geometry} % for wider text
\usepackage{xcolor}
\newenvironment{myquote}[2][5in]
{%
\begin{minipage}{#1}
\setlength{\leftskip}{\fill}%
\setlength{\rightskip}{-\leftskip}%
\setlength{\parfillskip}{\stretch{2}}%
\setlength{\emergencystretch}{\textwidth}% avoid overfull boxes if really possible
\pretolerance=0 % don't try the useless first pass
\hyphenpenalty=10000 % no hyphenation
\hbadness=10000 % don't report bad boxes
\frenchspacing % end of sentence space might become really wide
\bfseries
\textcolor{red}{#2:} \ignorespaces
}
{\end{minipage}}
\begin{document}
\begin{myquote}{Einstein on Simplicity}
``Out of Complexity, Find Simplicity.''
``Everything Should be Made as Simple as Possible, but Not Simpler.''
``If You Can't Explain It Simply, You Don't Understand It Well Enough.''
\end{myquote}
\bigskip
\begin{myquote}[4.5in]{Einstein on Simplicity}
``Out of Complexity, Find Simplicity.''
``Everything Should be Made as Simple as Possible, but Not Simpler.''
``If You Can't Explain It Simply, You Don't Understand It Well Enough.''
\end{myquote}
\bigskip
\begin{myquote}[4in]{Einstein on Simplicity}
``Out of Complexity, Find Simplicity.''
``Everything Should be Made as Simple as Possible, but Not Simpler.''
``If You Can't Explain It Simply, You Don't Understand It Well Enough.''
\end{myquote}
\end{document}
如果我删除\frenchspacing
,我会得到
无论如何,我认为这真的很糟糕。