Environment to get degressive text size like optic’s chat-like text












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?










share|improve this question

























  • 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















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?










share|improve this question

























  • 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












1








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?










share|improve this question
















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?







environments fontsize rendering






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 22 at 20:56









Bernard

175k776207




175k776207










asked Mar 22 at 20:45









fauvefauve

856514




856514













  • 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



















  • 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

















tex.stackexchange.com/q/423200 (unanswered) is somewhat similar.

– Thérèse
Mar 22 at 23:47





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





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 Answer
1






active

oldest

votes


















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}





share|improve this answer
























  • 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








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f480984%2fenvironment-to-get-degressive-text-size-like-optic-s-chat-like-text%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









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}





share|improve this answer
























  • 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
















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}





share|improve this answer
























  • 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














1












1








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}





share|improve this answer













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}






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 23 at 0:21









egregegreg

731k8819293246




731k8819293246













  • 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



















  • 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

















In a Galaxy far far away...

– KJO
Mar 23 at 0:24





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





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





@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





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





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


















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f480984%2fenvironment-to-get-degressive-text-size-like-optic-s-chat-like-text%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

ComboBox Display Member on multiple fields

Is it possible to collect Nectar points via Trainline?