如何在左对齐(\raggedright)文本中设置完全对齐?

如何在左对齐(\raggedright)文本中设置完全对齐?

如何在左对齐({\raggedright [...]})文本中设置完全对齐?

我需要充分论证的一个例子如下:

\documentclass{memoir}

\begin{document}

Document body.

\begin{thebibliography}{9}
  \SingleSpacing
\bibitem{ABC}
  {\raggedright \hyphenpenalty=10000 \exhyphenpenalty=10000
  Plenty of left-aligned text. Plenty of left-aligned text. Plenty of left-aligned text. Plenty of left-aligned text. Plenty of left-aligned text. Plenty of left-aligned text. Plenty of left-aligned text. Plenty of left-aligned text. Plenty of left-aligned text. Plenty of left-aligned text. Plenty of left-aligned text. Plenty of left-aligned text. Plenty of left-aligned text. Plenty of left-aligned text. Plenty of left-aligned text.
  \begin{list}{\(\bullet\)}
  \item Plenty of left-aligned text. Plenty of left-aligned text. Plenty of left-aligned text. Plenty of left-aligned text. Plenty of left-aligned text. Plenty of left-aligned text. Plenty of left-aligned text. \par
      \emph{Text I would like to be justified. Text I would like to be justified. Text I would like to be justified. Text I would like to be justified. Text I would like to be justified. Text I would like to be justified. Text I would like to be justified. Text I would like to be justified. Text I would like to be justified. Text I would like to be justified. Text I would like to be justified.}
  \end{list}
  }
\end{thebibliography}

\end{document}

这是不言自明的。

注意:可能还有更多最小的例子,但是(除了我在这个特定情况下需要充分的理由外)这个例子适用于某些明显的情况,例如“设置较小的范围不起作用” \raggedright

答案1

使用包ragged2e然后你就会有一个允许调整文本的宏:

\usepackage{ragged2e}
....
  {\justifying\emph{Text I would....}\par}

\par需要激活设置

答案2

\rightskip通过恢复和的含义\leftskip,也可以获得对齐的段落。将其包装在名为 的宏中,其\justified作用类似于\raggedleft\raggedright

\makeatletter
\newcommand{\justified}{%
  \rightskip\z@skip%
  \leftskip\z@skip}
\makeatother

如果您希望恢复段落缩进,也可以将其放在定义内\justified。默认为20pt

答案3

您可以将文本包装\parbox到 的集合中\linewidth。(我已使用该kantlipsum包来显示一些更真实的文本。)如评论中所述,此解决方案的一个缺点是结果不会跨页显示。对于某些目的,这可能是可以接受的,但对于大多数应用程序,最好\parbox使用 Herbert 使用该包的解决方案。ragged2e

\documentclass{memoir}
\usepackage{kantlipsum}
\begin{document}

Document body.

\begin{thebibliography}{9}
  \SingleSpacing
\bibitem{ABC}
  {\raggedright \hyphenpenalty=10000 \exhyphenpenalty=10000
  \kant[1]
  \begin{list}{\(\bullet\)}
  \item \kant[1]
      \parbox{\linewidth}{\emph{Text I would like to be justified. Text I would like to be justified. Text I would like to be justified. Text I would like to be justified. Text I would like to be justified. Text I would like to be justified. Text I would like to be justified. Text I would like to be justified. Text I would like to be justified. Text I would like to be justified. Text I would like to be justified.}}
  \end{list}
  }
\end{thebibliography}

\end{document}

代码输出

相关内容