1

The goal is to get with the following MWE

\documentclass{book}


\begin{document}

\begin{degressive}
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam. Maecenas ligula massa, varius a, semper congue, euismod non, mi. Proin porttitor, orci nec nonummy molestie, enim est eleifend mi, non fermentum diam nisl sit amet erat. Duis semper. Duis arcu massa, scelerisque vitae, consequat in, pretium a, enim. Pellentesque congue. Ut in risus volutpat libero pharetra tempor. Cras vestibulum bibendum augue. Praesent egestas leo in pede. Praesent blandit odio eu enim. Pellentesque sed dui ut augue blandit sodales. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aliquam nibh. Mauris ac mauris sed pede pellentesque fermentum. Maecenas adipiscing ante non diam sodales hendrerit.
\end{degressive}

\end{document}

A rendering (approximatively) like this one:

Explanation: Each line have to get a text-size smaller than the precedent one (it could be, as example {400%, 300%, 200%, 150%} of normal text size). BUT the environment should ideally round the text size to feat text width and to preserve fancy word spacing.

So, who to build an environment like this one?

  • tex.stackexchange.com/q/423200 (unanswered) is somewhat similar. – Thérèse Mar 22 at 23:47
  • Interesting. I find by this way the magaz package witch make what I search but only for the first line. – fauve Mar 23 at 0:10
1

A proof of concept:

\documentclass{book}
\usepackage{xparse}
\usepackage{lmodern}

\ExplSyntaxOn

\NewDocumentEnvironment{degressive}{b}
 {
  \frenchspacing
  \setlength{\parindent}{0pt}
  \fauve_degressive:n { #1 }
 }
 {}

\seq_new:N \l__fauve_degressive_text_seq
\seq_new:N \l__fauve_degressive_tentative_seq
\tl_new:N \l__fauve_degressive_word_tl
\box_new:N \l__fauve_degressive_tentative_box

\cs_new_protected:Nn \fauve_degressive:n
 {
  \seq_set_split:Nnn \l__fauve_degressive_text_seq { ~ } { #1 }
  % first line at 30pt size
  \seq_clear:N \l__fauve_degressive_tentative_seq
  \__fauve_degressive_line:n { 30 }
  % second line at 25pt size
  \seq_clear:N \l__fauve_degressive_tentative_seq
  \__fauve_degressive_line:n { 25 }
  % third line at 20pt size
  \seq_clear:N \l__fauve_degressive_tentative_seq
  \__fauve_degressive_line:n { 20 }
  % fourth line at 15pt size
  \seq_clear:N \l__fauve_degressive_tentative_seq
  \__fauve_degressive_line:n { 15 }
  % the rest
  \seq_use:Nn \l__fauve_degressive_text_seq { ~ } \par
 }

\cs_new_protected:Nn \__fauve_degressive_line:n
 {
  \seq_pop_left:NN \l__fauve_degressive_text_seq \l__fauve_degressive_word_tl
  \hbox_set:Nn \l__fauve_degressive_tentative_box
   {
    \fontsize{#1}{0}\selectfont
    \seq_use:Nn \l__fauve_degressive_tentative_seq { ~ } ~ 
    \l__fauve_degressive_word_tl
   }
  \dim_compare:nTF
   {
    \box_wd:N \l__fauve_degressive_tentative_box > \textwidth
   }
   {% the previous attempt was the maximum
    {
     \fontsize{#1}{\fp_eval:n{1.2*(#1)}}\selectfont
     \seq_use:Nn \l__fauve_degressive_tentative_seq { ~ }
     \setlength{\parfillskip}{0pt}\par
    }
    \seq_put_left:NV \l__fauve_degressive_text_seq \l__fauve_degressive_word_tl
   }
   {% do it again
    \seq_put_right:NV \l__fauve_degressive_tentative_seq \l__fauve_degressive_word_tl
    \__fauve_degressive_line:n { #1 }
   }
 }

\ExplSyntaxOff

\begin{document}

\begin{degressive}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
Sed non risus. Suspendisse lectus tortor, dignissim sit 
amet, adipiscing nec, ultricies sed, dolor. Cras elementum 
ultrices diam. Maecenas ligula massa, varius a, semper 
congue, euismod non, mi. Proin porttitor, orci nec nonummy 
molestie, enim est eleifend mi, non fermentum diam nisl sit 
amet erat. Duis semper. Duis arcu massa, scelerisque vitae, 
consequat in, pretium a, enim. Pellentesque congue. Ut in 
risus volutpat libero pharetra tempor. Cras vestibulum 
bibendum augue. Praesent egestas leo in pede. Praesent 
blandit odio eu enim. Pellentesque sed dui ut augue blandit 
sodales. Vestibulum ante ipsum primis in faucibus orci 
luctus et ultrices posuere cubilia Curae; Aliquam nibh. 
Mauris ac mauris sed pede pellentesque fermentum. Maecenas 
adipiscing ante non diam sodales hendrerit.
\end{degressive}

\end{document}

enter image description here

If you don't have xparse version 2019-03-05 (or later), use environ:

\documentclass{book}
\usepackage{xparse}
\usepackage{lmodern}
\usepackage{environ}

\ExplSyntaxOn

\NewEnviron{degressive}
 {
  \frenchspacing
  \setlength{\parindent}{0pt}
  \fauve_degressive:V \BODY
 }

\seq_new:N \l__fauve_degressive_text_seq
\seq_new:N \l__fauve_degressive_tentative_seq
\tl_new:N \l__fauve_degressive_word_tl
\box_new:N \l__fauve_degressive_tentative_box

\cs_new_protected:Nn \fauve_degressive:n
 {
  \seq_set_split:Nnn \l__fauve_degressive_text_seq { ~ } { #1 }
  % first line at 30pt size
  \seq_clear:N \l__fauve_degressive_tentative_seq
  \__fauve_degressive_line:n { 30 }
  % second line at 25pt size
  \seq_clear:N \l__fauve_degressive_tentative_seq
  \__fauve_degressive_line:n { 25 }
  % third line at 20pt size
  \seq_clear:N \l__fauve_degressive_tentative_seq
  \__fauve_degressive_line:n { 20 }
  % fourth line at 15pt size
  \seq_clear:N \l__fauve_degressive_tentative_seq
  \__fauve_degressive_line:n { 15 }
  % the rest
  \seq_use:Nn \l__fauve_degressive_text_seq { ~ } \par
 }
\cs_generate_variant:Nn \fauve_degressive:n { V }

\cs_new_protected:Nn \__fauve_degressive_line:n
 {
  \seq_pop_left:NN \l__fauve_degressive_text_seq \l__fauve_degressive_word_tl
  \hbox_set:Nn \l__fauve_degressive_tentative_box
   {
    \fontsize{#1}{0}\selectfont
    \seq_use:Nn \l__fauve_degressive_tentative_seq { ~ } ~ 
    \l__fauve_degressive_word_tl
   }
  \dim_compare:nTF
   {
    \box_wd:N \l__fauve_degressive_tentative_box > \textwidth
   }
   {% the previous attempt was the maximum
    {
     \fontsize{#1}{\fp_eval:n{1.2*(#1)}}\selectfont
     \seq_use:Nn \l__fauve_degressive_tentative_seq { ~ }
     \setlength{\parfillskip}{0pt}\par
    }
    \seq_put_left:NV \l__fauve_degressive_text_seq \l__fauve_degressive_word_tl
   }
   {% do it again
    \seq_put_right:NV \l__fauve_degressive_tentative_seq \l__fauve_degressive_word_tl
    \__fauve_degressive_line:n { #1 }
   }
 }

\ExplSyntaxOff

\begin{document}

\begin{degressive}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
Sed non risus. Suspendisse lectus tortor, dignissim sit 
amet, adipiscing nec, ultricies sed, dolor. Cras elementum 
ultrices diam. Maecenas ligula massa, varius a, semper 
congue, euismod non, mi. Proin porttitor, orci nec nonummy 
molestie, enim est eleifend mi, non fermentum diam nisl sit 
amet erat. Duis semper. Duis arcu massa, scelerisque vitae, 
consequat in, pretium a, enim. Pellentesque congue. Ut in 
risus volutpat libero pharetra tempor. Cras vestibulum 
bibendum augue. Praesent egestas leo in pede. Praesent 
blandit odio eu enim. Pellentesque sed dui ut augue blandit 
sodales. Vestibulum ante ipsum primis in faucibus orci 
luctus et ultrices posuere cubilia Curae; Aliquam nibh. 
Mauris ac mauris sed pede pellentesque fermentum. Maecenas 
adipiscing ante non diam sodales hendrerit.
\end{degressive}

\end{document}
  • In a Galaxy far far away... – KJO Mar 23 at 0:24
  • So, honestly. For me it’s sufficient, but in order to make a new package, is it possible to do it without the call to xparse package? =) – fauve Mar 23 at 0:28
  • @fauve What's the problem with xparse? – egreg Mar 23 at 0:31
  • There is no big problem, it’s just to make this new package could work without another one. But, if it’s to much work for noting important, it’s absolutely not necessary :) – fauve Mar 23 at 0:55
  • So, I test it, and it still an important problem. The environement `degressive’ could not be used in another environment or command. It only could be directly used :/ – fauve Mar 23 at 17:36

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.