1

As I avoid the space at the end of the lines. I want the last word of each line to touch the edge of the minipage but not to exceed it. Each line has to stay as it is, one should not remove or include words, or change words between two lines. I can not use \ spaceskip to rearrange each line individually. The first word of each line should touch the right edge of the minipage just as it is in the image below. The distribution of the words should be agreeable in the end. Lines that have only one word are not a problem as long as the word remains in the text. I want to know a global solution, such as a style, or package, or command, etc.

Text sample

\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}

Hi @leandriis, here a code using \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}

and the result

Don't work

  • 1
    Possibly related? fully stretch text horizontally on page – leandriis Feb 24 at 22:30
  • Sorry, but after reading your question several times, I can't understand what the request is. – egreg Feb 24 at 22:34
  • 1
    are you just saying that you want forced line breaks but stretching the words not leaving the line short? In which case you want \linebreak not \\ but your question is very unclear – David Carlisle Feb 24 at 22:36
  • Hi @leandriis, use \ makebox [\ linewidth] [s] did not work as shown in the second image of my question. One of the lines crossed the border. – Diego Bnei Noah Feb 24 at 22:55
3

I am not sure, but I think you are asking for

enter image description here

\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}
  • 1
    This is using forced breaks as you seem to want and forces every line to be full width, but the spacing of course is not agreeable, but I could not understand your question if it was not asking for this. – David Carlisle Feb 24 at 22:41
  • Hi @DavidCarlisle, Although the result has a very large spacing between words, this does not sound unpleasant, but depends on the width of the minipage. Your response was great. Thank you! Thank you all! – Diego Bnei Noah Feb 24 at 22:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.