小页:每行末尾的单词触及小页的边框,但不超过空格

小页:每行末尾的单词触及小页的边框,但不超过空格

因为我避免在行尾留空格。我希望每行的最后一个单词触及小页面的边缘但不超过它。每行必须保持原样,不应删除或包含单词,也不应在两行之间更改单词。我无法使用 \ spaceskip 单独重新排列每行。每行的第一个单词应该触及小页面的右边缘,就像下图中一样。单词的分布最终应该是一致的。只有一个单词的行没有问题,只要该单词保留在文本中。我想知道一个全局解决方案,例如样式、包或命令等。

文本示例

\documentclass{article}
\usepackage{fancybox,anyfontsize,geometry,setspace}
\thispagestyle{empty}
\paperwidth=15.0in
\paperheight=13.0in
\addtolength{\textwidth}{12.55in}
\addtolength{\textheight}{6.90in}
\begin{document}
\fbox{
\begin{minipage}{0.45\textwidth}
    \begin{spacing}{9}  
\fontsize{40}{6}\selectfont

\spaceskip=1.78\fontdimen2\font plus 1.2\fontdimen3\font minus 1.2\fontdimen4\font 
Deep down, I know I do \\
great work! I literally \\
study every single day, \\
and I work on huge projects at work. I've been in \\
the field for over 15 years. I work with \\
and even challenge some of the \\
best developers.
\end{spacing}
\end{minipage}
} 
\end{document}

你好@leandriis,这里有一个使用 \makebox[\linewidth][s] 的代码:

\documentclass{article}
\usepackage{fancybox,anyfontsize,geometry,setspace}
\thispagestyle{empty}
\paperwidth=15.0in
\paperheight=13.0in
\addtolength{\textwidth}{12.55in}
\addtolength{\textheight}{6.90in}
\begin{document}
\fbox{
\begin{minipage}{0.45\textwidth}
    \begin{spacing}{9}  
\fontsize{40}{6}\selectfont

\spaceskip=1.78\fontdimen2\font plus 1.2\fontdimen3\font minus 1.2\fontdimen4\font 
\makebox[\linewidth][s]{Deep down, I know I do} \\
\makebox[\linewidth][s]{great work! I literally} \\
\makebox[\linewidth][s]{study every single day,} \\
\makebox[\linewidth][s]{and I work on huge projects at work. I've been in} \\
\makebox[\linewidth][s]{the field for over 15 years. I work with} \\
\makebox[\linewidth][s]{and even challenge some of the} \\
\makebox[\linewidth][s]{best developers.}
\end{spacing}
\end{minipage}
} 
\end{document}

结果

不工作

答案1

我不确定,但我认为你问的是

在此处输入图片描述

\documentclass{article}
\usepackage{fancybox,anyfontsize,geometry,setspace}
\thispagestyle{empty}
\paperwidth=15.0in
\paperheight=13.0in
\addtolength{\textwidth}{12.55in}
\addtolength{\textheight}{6.90in}
\begin{document}
\fbox{
\begin{minipage}{0.45\textwidth}
    \begin{spacing}{9}  
\fontsize{40}{6}\selectfont

\emergencystretch\linewidth\parfillskip0pt
Deep down, I know I do\linebreak
great work! I literally\linebreak
study every single day,\linebreak
and I work on huge projects at work. I've been in\linebreak
the field for over 15 years. I work with\linebreak
and even challenge some of the\linebreak
best developers.
\end{spacing}
\end{minipage}
} 
\end{document}

相关内容