Align last word of paragraph to right with raggedright












5














I want to align the last word of a paragraph to the right like this example from The TeXbook.



This works great with a justified paragraph, but fails with a raggedright paragraph.



In case it's relevant, my specific example in the MWE example below includes a slightly more complicated paragraph setup for typesetting psalms based on code from this answer.



There are two issues with my current set up.




  1. The second to last word in the paragraph wraps on to the last line even when there is space for it on the previous line.

  2. The last word of the paragraph (Selah) is not set flush right.


I also want to avoid hyphenation.



documentclass{article}

usepackage{xparse}
usepackage[showframe,textwidth=5.6cm,textheight=10cm]{geometry}
parindent 0em

ExplSyntaxOn

dim_new:N l__scripture_indent_dim

dim_set:Nn l__scripture_indent_dim { 1em }

cs_new:Nn scripture_vs:n
{
textsuperscript {#1}
}

cs_new:Nn scripture_vs_overlap_left:n
{
hbox_overlap_left:n
{
scripture_vs:n {#1}
}
}

cs_new:Nn scripture_format_selah:n
{
emph {#1}
}

cs_new:Nn scripture_selah:
{
{
unskip
nobreak
hfil
penalty 50
skip_horizontal:N 2em
hbox:n {}
nobreak
hfil
scripture_format_selah:n { Selah }
parfillskip = 0pt
finalhyphendemerits = 0
endgraf
skip_vertical:n { -baselineskip }
leavevmode
}
}

cs_new:Nn scripture_vs_outdent_overlap_left:n
{
skip_horizontal:N -l__scripture_indent_dim
scripture_vs_overlap_left:n {#1}
skip_horizontal:N l__scripture_indent_dim
}

cs_new_protected:Nn scripture_psalm_par:
{
mode_if_vertical:TF
{
cs_set_eq:NN vs scripture_vs_overlap_left:n
noindent
}
{
cs_set_eq:NN vs scripture_vs_outdent_overlap_left:n
endgraf
}
dim_set:Nn hangindent { 4 l__scripture_indent_dim }
}

NewDocumentCommand selah { }
{
scripture_selah:
}

NewDocumentEnvironment {psalm} { }
{
raggedright
cs_set_eq:NN vs scripture_vs_overlap_left:n
cs_set_eq:NN par scripture_psalm_par:
dim_set_eq:NN leftskip l__scripture_indent_dim
dim_set_eq:NN parindent l__scripture_indent_dim
obeylines
}
{ }

ExplSyntaxOff

begin{document}

section*{What I get}

begin{psalm}
vs{1}textsc{Lord}, how many are my foes!
How many rise up against me!

vs{2}Many are saying of me,
‘God will not deliver him.’selahmedskip

vs{3}But you, textsc{Lord}, are a shield around me,
my glory, the One who lifts my head high.

vs{4}I call out to the Lord,
and he answers me from his holy mountain.selah
end{psalm}

section*{What I'd like}

hspace*{2em}`God will not deliver him.'selah

medskip

hspace*{2em}and he answers me from his \
hspace*{5em}holy mountain.selah

end{document}


output










share|improve this question



























    5














    I want to align the last word of a paragraph to the right like this example from The TeXbook.



    This works great with a justified paragraph, but fails with a raggedright paragraph.



    In case it's relevant, my specific example in the MWE example below includes a slightly more complicated paragraph setup for typesetting psalms based on code from this answer.



    There are two issues with my current set up.




    1. The second to last word in the paragraph wraps on to the last line even when there is space for it on the previous line.

    2. The last word of the paragraph (Selah) is not set flush right.


    I also want to avoid hyphenation.



    documentclass{article}

    usepackage{xparse}
    usepackage[showframe,textwidth=5.6cm,textheight=10cm]{geometry}
    parindent 0em

    ExplSyntaxOn

    dim_new:N l__scripture_indent_dim

    dim_set:Nn l__scripture_indent_dim { 1em }

    cs_new:Nn scripture_vs:n
    {
    textsuperscript {#1}
    }

    cs_new:Nn scripture_vs_overlap_left:n
    {
    hbox_overlap_left:n
    {
    scripture_vs:n {#1}
    }
    }

    cs_new:Nn scripture_format_selah:n
    {
    emph {#1}
    }

    cs_new:Nn scripture_selah:
    {
    {
    unskip
    nobreak
    hfil
    penalty 50
    skip_horizontal:N 2em
    hbox:n {}
    nobreak
    hfil
    scripture_format_selah:n { Selah }
    parfillskip = 0pt
    finalhyphendemerits = 0
    endgraf
    skip_vertical:n { -baselineskip }
    leavevmode
    }
    }

    cs_new:Nn scripture_vs_outdent_overlap_left:n
    {
    skip_horizontal:N -l__scripture_indent_dim
    scripture_vs_overlap_left:n {#1}
    skip_horizontal:N l__scripture_indent_dim
    }

    cs_new_protected:Nn scripture_psalm_par:
    {
    mode_if_vertical:TF
    {
    cs_set_eq:NN vs scripture_vs_overlap_left:n
    noindent
    }
    {
    cs_set_eq:NN vs scripture_vs_outdent_overlap_left:n
    endgraf
    }
    dim_set:Nn hangindent { 4 l__scripture_indent_dim }
    }

    NewDocumentCommand selah { }
    {
    scripture_selah:
    }

    NewDocumentEnvironment {psalm} { }
    {
    raggedright
    cs_set_eq:NN vs scripture_vs_overlap_left:n
    cs_set_eq:NN par scripture_psalm_par:
    dim_set_eq:NN leftskip l__scripture_indent_dim
    dim_set_eq:NN parindent l__scripture_indent_dim
    obeylines
    }
    { }

    ExplSyntaxOff

    begin{document}

    section*{What I get}

    begin{psalm}
    vs{1}textsc{Lord}, how many are my foes!
    How many rise up against me!

    vs{2}Many are saying of me,
    ‘God will not deliver him.’selahmedskip

    vs{3}But you, textsc{Lord}, are a shield around me,
    my glory, the One who lifts my head high.

    vs{4}I call out to the Lord,
    and he answers me from his holy mountain.selah
    end{psalm}

    section*{What I'd like}

    hspace*{2em}`God will not deliver him.'selah

    medskip

    hspace*{2em}and he answers me from his \
    hspace*{5em}holy mountain.selah

    end{document}


    output










    share|improve this question

























      5












      5








      5







      I want to align the last word of a paragraph to the right like this example from The TeXbook.



      This works great with a justified paragraph, but fails with a raggedright paragraph.



      In case it's relevant, my specific example in the MWE example below includes a slightly more complicated paragraph setup for typesetting psalms based on code from this answer.



      There are two issues with my current set up.




      1. The second to last word in the paragraph wraps on to the last line even when there is space for it on the previous line.

      2. The last word of the paragraph (Selah) is not set flush right.


      I also want to avoid hyphenation.



      documentclass{article}

      usepackage{xparse}
      usepackage[showframe,textwidth=5.6cm,textheight=10cm]{geometry}
      parindent 0em

      ExplSyntaxOn

      dim_new:N l__scripture_indent_dim

      dim_set:Nn l__scripture_indent_dim { 1em }

      cs_new:Nn scripture_vs:n
      {
      textsuperscript {#1}
      }

      cs_new:Nn scripture_vs_overlap_left:n
      {
      hbox_overlap_left:n
      {
      scripture_vs:n {#1}
      }
      }

      cs_new:Nn scripture_format_selah:n
      {
      emph {#1}
      }

      cs_new:Nn scripture_selah:
      {
      {
      unskip
      nobreak
      hfil
      penalty 50
      skip_horizontal:N 2em
      hbox:n {}
      nobreak
      hfil
      scripture_format_selah:n { Selah }
      parfillskip = 0pt
      finalhyphendemerits = 0
      endgraf
      skip_vertical:n { -baselineskip }
      leavevmode
      }
      }

      cs_new:Nn scripture_vs_outdent_overlap_left:n
      {
      skip_horizontal:N -l__scripture_indent_dim
      scripture_vs_overlap_left:n {#1}
      skip_horizontal:N l__scripture_indent_dim
      }

      cs_new_protected:Nn scripture_psalm_par:
      {
      mode_if_vertical:TF
      {
      cs_set_eq:NN vs scripture_vs_overlap_left:n
      noindent
      }
      {
      cs_set_eq:NN vs scripture_vs_outdent_overlap_left:n
      endgraf
      }
      dim_set:Nn hangindent { 4 l__scripture_indent_dim }
      }

      NewDocumentCommand selah { }
      {
      scripture_selah:
      }

      NewDocumentEnvironment {psalm} { }
      {
      raggedright
      cs_set_eq:NN vs scripture_vs_overlap_left:n
      cs_set_eq:NN par scripture_psalm_par:
      dim_set_eq:NN leftskip l__scripture_indent_dim
      dim_set_eq:NN parindent l__scripture_indent_dim
      obeylines
      }
      { }

      ExplSyntaxOff

      begin{document}

      section*{What I get}

      begin{psalm}
      vs{1}textsc{Lord}, how many are my foes!
      How many rise up against me!

      vs{2}Many are saying of me,
      ‘God will not deliver him.’selahmedskip

      vs{3}But you, textsc{Lord}, are a shield around me,
      my glory, the One who lifts my head high.

      vs{4}I call out to the Lord,
      and he answers me from his holy mountain.selah
      end{psalm}

      section*{What I'd like}

      hspace*{2em}`God will not deliver him.'selah

      medskip

      hspace*{2em}and he answers me from his \
      hspace*{5em}holy mountain.selah

      end{document}


      output










      share|improve this question













      I want to align the last word of a paragraph to the right like this example from The TeXbook.



      This works great with a justified paragraph, but fails with a raggedright paragraph.



      In case it's relevant, my specific example in the MWE example below includes a slightly more complicated paragraph setup for typesetting psalms based on code from this answer.



      There are two issues with my current set up.




      1. The second to last word in the paragraph wraps on to the last line even when there is space for it on the previous line.

      2. The last word of the paragraph (Selah) is not set flush right.


      I also want to avoid hyphenation.



      documentclass{article}

      usepackage{xparse}
      usepackage[showframe,textwidth=5.6cm,textheight=10cm]{geometry}
      parindent 0em

      ExplSyntaxOn

      dim_new:N l__scripture_indent_dim

      dim_set:Nn l__scripture_indent_dim { 1em }

      cs_new:Nn scripture_vs:n
      {
      textsuperscript {#1}
      }

      cs_new:Nn scripture_vs_overlap_left:n
      {
      hbox_overlap_left:n
      {
      scripture_vs:n {#1}
      }
      }

      cs_new:Nn scripture_format_selah:n
      {
      emph {#1}
      }

      cs_new:Nn scripture_selah:
      {
      {
      unskip
      nobreak
      hfil
      penalty 50
      skip_horizontal:N 2em
      hbox:n {}
      nobreak
      hfil
      scripture_format_selah:n { Selah }
      parfillskip = 0pt
      finalhyphendemerits = 0
      endgraf
      skip_vertical:n { -baselineskip }
      leavevmode
      }
      }

      cs_new:Nn scripture_vs_outdent_overlap_left:n
      {
      skip_horizontal:N -l__scripture_indent_dim
      scripture_vs_overlap_left:n {#1}
      skip_horizontal:N l__scripture_indent_dim
      }

      cs_new_protected:Nn scripture_psalm_par:
      {
      mode_if_vertical:TF
      {
      cs_set_eq:NN vs scripture_vs_overlap_left:n
      noindent
      }
      {
      cs_set_eq:NN vs scripture_vs_outdent_overlap_left:n
      endgraf
      }
      dim_set:Nn hangindent { 4 l__scripture_indent_dim }
      }

      NewDocumentCommand selah { }
      {
      scripture_selah:
      }

      NewDocumentEnvironment {psalm} { }
      {
      raggedright
      cs_set_eq:NN vs scripture_vs_overlap_left:n
      cs_set_eq:NN par scripture_psalm_par:
      dim_set_eq:NN leftskip l__scripture_indent_dim
      dim_set_eq:NN parindent l__scripture_indent_dim
      obeylines
      }
      { }

      ExplSyntaxOff

      begin{document}

      section*{What I get}

      begin{psalm}
      vs{1}textsc{Lord}, how many are my foes!
      How many rise up against me!

      vs{2}Many are saying of me,
      ‘God will not deliver him.’selahmedskip

      vs{3}But you, textsc{Lord}, are a shield around me,
      my glory, the One who lifts my head high.

      vs{4}I call out to the Lord,
      and he answers me from his holy mountain.selah
      end{psalm}

      section*{What I'd like}

      hspace*{2em}`God will not deliver him.'selah

      medskip

      hspace*{2em}and he answers me from his \
      hspace*{5em}holy mountain.selah

      end{document}


      output







      horizontal-alignment






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 18 '18 at 3:45









      David Purton

      8,7851834




      8,7851834






















          1 Answer
          1






          active

          oldest

          votes


















          4














          Looks like you can slightly modify the scripture_selah definition. I added the hspace*{0.025textwidth} just to make sure there is some extra space, so that Selah is padded and not immediately flush (if there is enough space, e.g. with him.').



          (version using only primitives)



          cs_new:Nn scripture_selah:
          {
          hfillnull%
          penalty -5%
          nullhfill%
          kern 1emscripture_format_selah:n {Selah}%
          skip_vertical:n { -baselineskip }
          leavevmode
          }


          (minimal changes version)



          cs_new:Nn scripture_selah:
          {
          {
          unskip
          hfil
          penalty 50
          hbox:n {}
          nobreak
          hspace*{fill}
          scripture_format_selah:n { hspace*{0.025textwidth}Selah }
          parfillskip = 0pt
          finalhyphendemerits = 0
          endgraf
          skip_vertical:n { -baselineskip }
          leavevmode
          }
          }


          (version with minimal code)



          cs_new:Nn scripture_selah:
          {
          {
          hfil
          penalty 50
          hspace*{fill}
          scripture_format_selah:n { hspace*{0.025textwidth}Selah }
          skip_vertical:n { -baselineskip }
          leavevmode
          }
          }


          modified horizontal formatting



          This works in the particular example that you provided. I am not sure if this will robustly work in every situation that you will be using it in.



          EDIT:



          I was looking more into hbox:n and I really don't think you want to use it here (see my "version with minimal code"). It is meant roughly as a hook just before par. If you wrap scripture_format_selah:n within hbox:n (i.e. hbox:n {scripture_format_selah:n ...}, you will get the same result as without using hbox:n in this situation. Therefore, I opted to ignore it.






          share|improve this answer























          • Thanks. I'll do some experimenting. I don't claim to fully understand the code from the TeXbook, but my use case is simpler in some respects so the code may be able to be simplified.
            – David Purton
            Dec 18 '18 at 5:43










          • BTW, using hspace* is essentially doing the same as the hbox:n{}nobreak, so you're still using it.
            – David Purton
            Dec 18 '18 at 6:33










          • @DavidPurton I added a new version (at the top) using only plain TeX primitives. Not sure if you prefer this one, but it works because of the penalty -5 which coaxes a line break (but not strongly). For example, it still produces the image above, but for #2, if you delete him then Selah jumps up to the same line as the text.
            – whatisit
            Dec 19 '18 at 2:44











          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%2f466306%2falign-last-word-of-paragraph-to-right-with-raggedright%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









          4














          Looks like you can slightly modify the scripture_selah definition. I added the hspace*{0.025textwidth} just to make sure there is some extra space, so that Selah is padded and not immediately flush (if there is enough space, e.g. with him.').



          (version using only primitives)



          cs_new:Nn scripture_selah:
          {
          hfillnull%
          penalty -5%
          nullhfill%
          kern 1emscripture_format_selah:n {Selah}%
          skip_vertical:n { -baselineskip }
          leavevmode
          }


          (minimal changes version)



          cs_new:Nn scripture_selah:
          {
          {
          unskip
          hfil
          penalty 50
          hbox:n {}
          nobreak
          hspace*{fill}
          scripture_format_selah:n { hspace*{0.025textwidth}Selah }
          parfillskip = 0pt
          finalhyphendemerits = 0
          endgraf
          skip_vertical:n { -baselineskip }
          leavevmode
          }
          }


          (version with minimal code)



          cs_new:Nn scripture_selah:
          {
          {
          hfil
          penalty 50
          hspace*{fill}
          scripture_format_selah:n { hspace*{0.025textwidth}Selah }
          skip_vertical:n { -baselineskip }
          leavevmode
          }
          }


          modified horizontal formatting



          This works in the particular example that you provided. I am not sure if this will robustly work in every situation that you will be using it in.



          EDIT:



          I was looking more into hbox:n and I really don't think you want to use it here (see my "version with minimal code"). It is meant roughly as a hook just before par. If you wrap scripture_format_selah:n within hbox:n (i.e. hbox:n {scripture_format_selah:n ...}, you will get the same result as without using hbox:n in this situation. Therefore, I opted to ignore it.






          share|improve this answer























          • Thanks. I'll do some experimenting. I don't claim to fully understand the code from the TeXbook, but my use case is simpler in some respects so the code may be able to be simplified.
            – David Purton
            Dec 18 '18 at 5:43










          • BTW, using hspace* is essentially doing the same as the hbox:n{}nobreak, so you're still using it.
            – David Purton
            Dec 18 '18 at 6:33










          • @DavidPurton I added a new version (at the top) using only plain TeX primitives. Not sure if you prefer this one, but it works because of the penalty -5 which coaxes a line break (but not strongly). For example, it still produces the image above, but for #2, if you delete him then Selah jumps up to the same line as the text.
            – whatisit
            Dec 19 '18 at 2:44
















          4














          Looks like you can slightly modify the scripture_selah definition. I added the hspace*{0.025textwidth} just to make sure there is some extra space, so that Selah is padded and not immediately flush (if there is enough space, e.g. with him.').



          (version using only primitives)



          cs_new:Nn scripture_selah:
          {
          hfillnull%
          penalty -5%
          nullhfill%
          kern 1emscripture_format_selah:n {Selah}%
          skip_vertical:n { -baselineskip }
          leavevmode
          }


          (minimal changes version)



          cs_new:Nn scripture_selah:
          {
          {
          unskip
          hfil
          penalty 50
          hbox:n {}
          nobreak
          hspace*{fill}
          scripture_format_selah:n { hspace*{0.025textwidth}Selah }
          parfillskip = 0pt
          finalhyphendemerits = 0
          endgraf
          skip_vertical:n { -baselineskip }
          leavevmode
          }
          }


          (version with minimal code)



          cs_new:Nn scripture_selah:
          {
          {
          hfil
          penalty 50
          hspace*{fill}
          scripture_format_selah:n { hspace*{0.025textwidth}Selah }
          skip_vertical:n { -baselineskip }
          leavevmode
          }
          }


          modified horizontal formatting



          This works in the particular example that you provided. I am not sure if this will robustly work in every situation that you will be using it in.



          EDIT:



          I was looking more into hbox:n and I really don't think you want to use it here (see my "version with minimal code"). It is meant roughly as a hook just before par. If you wrap scripture_format_selah:n within hbox:n (i.e. hbox:n {scripture_format_selah:n ...}, you will get the same result as without using hbox:n in this situation. Therefore, I opted to ignore it.






          share|improve this answer























          • Thanks. I'll do some experimenting. I don't claim to fully understand the code from the TeXbook, but my use case is simpler in some respects so the code may be able to be simplified.
            – David Purton
            Dec 18 '18 at 5:43










          • BTW, using hspace* is essentially doing the same as the hbox:n{}nobreak, so you're still using it.
            – David Purton
            Dec 18 '18 at 6:33










          • @DavidPurton I added a new version (at the top) using only plain TeX primitives. Not sure if you prefer this one, but it works because of the penalty -5 which coaxes a line break (but not strongly). For example, it still produces the image above, but for #2, if you delete him then Selah jumps up to the same line as the text.
            – whatisit
            Dec 19 '18 at 2:44














          4












          4








          4






          Looks like you can slightly modify the scripture_selah definition. I added the hspace*{0.025textwidth} just to make sure there is some extra space, so that Selah is padded and not immediately flush (if there is enough space, e.g. with him.').



          (version using only primitives)



          cs_new:Nn scripture_selah:
          {
          hfillnull%
          penalty -5%
          nullhfill%
          kern 1emscripture_format_selah:n {Selah}%
          skip_vertical:n { -baselineskip }
          leavevmode
          }


          (minimal changes version)



          cs_new:Nn scripture_selah:
          {
          {
          unskip
          hfil
          penalty 50
          hbox:n {}
          nobreak
          hspace*{fill}
          scripture_format_selah:n { hspace*{0.025textwidth}Selah }
          parfillskip = 0pt
          finalhyphendemerits = 0
          endgraf
          skip_vertical:n { -baselineskip }
          leavevmode
          }
          }


          (version with minimal code)



          cs_new:Nn scripture_selah:
          {
          {
          hfil
          penalty 50
          hspace*{fill}
          scripture_format_selah:n { hspace*{0.025textwidth}Selah }
          skip_vertical:n { -baselineskip }
          leavevmode
          }
          }


          modified horizontal formatting



          This works in the particular example that you provided. I am not sure if this will robustly work in every situation that you will be using it in.



          EDIT:



          I was looking more into hbox:n and I really don't think you want to use it here (see my "version with minimal code"). It is meant roughly as a hook just before par. If you wrap scripture_format_selah:n within hbox:n (i.e. hbox:n {scripture_format_selah:n ...}, you will get the same result as without using hbox:n in this situation. Therefore, I opted to ignore it.






          share|improve this answer














          Looks like you can slightly modify the scripture_selah definition. I added the hspace*{0.025textwidth} just to make sure there is some extra space, so that Selah is padded and not immediately flush (if there is enough space, e.g. with him.').



          (version using only primitives)



          cs_new:Nn scripture_selah:
          {
          hfillnull%
          penalty -5%
          nullhfill%
          kern 1emscripture_format_selah:n {Selah}%
          skip_vertical:n { -baselineskip }
          leavevmode
          }


          (minimal changes version)



          cs_new:Nn scripture_selah:
          {
          {
          unskip
          hfil
          penalty 50
          hbox:n {}
          nobreak
          hspace*{fill}
          scripture_format_selah:n { hspace*{0.025textwidth}Selah }
          parfillskip = 0pt
          finalhyphendemerits = 0
          endgraf
          skip_vertical:n { -baselineskip }
          leavevmode
          }
          }


          (version with minimal code)



          cs_new:Nn scripture_selah:
          {
          {
          hfil
          penalty 50
          hspace*{fill}
          scripture_format_selah:n { hspace*{0.025textwidth}Selah }
          skip_vertical:n { -baselineskip }
          leavevmode
          }
          }


          modified horizontal formatting



          This works in the particular example that you provided. I am not sure if this will robustly work in every situation that you will be using it in.



          EDIT:



          I was looking more into hbox:n and I really don't think you want to use it here (see my "version with minimal code"). It is meant roughly as a hook just before par. If you wrap scripture_format_selah:n within hbox:n (i.e. hbox:n {scripture_format_selah:n ...}, you will get the same result as without using hbox:n in this situation. Therefore, I opted to ignore it.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 19 '18 at 2:38

























          answered Dec 18 '18 at 4:24









          whatisit

          862313




          862313












          • Thanks. I'll do some experimenting. I don't claim to fully understand the code from the TeXbook, but my use case is simpler in some respects so the code may be able to be simplified.
            – David Purton
            Dec 18 '18 at 5:43










          • BTW, using hspace* is essentially doing the same as the hbox:n{}nobreak, so you're still using it.
            – David Purton
            Dec 18 '18 at 6:33










          • @DavidPurton I added a new version (at the top) using only plain TeX primitives. Not sure if you prefer this one, but it works because of the penalty -5 which coaxes a line break (but not strongly). For example, it still produces the image above, but for #2, if you delete him then Selah jumps up to the same line as the text.
            – whatisit
            Dec 19 '18 at 2:44


















          • Thanks. I'll do some experimenting. I don't claim to fully understand the code from the TeXbook, but my use case is simpler in some respects so the code may be able to be simplified.
            – David Purton
            Dec 18 '18 at 5:43










          • BTW, using hspace* is essentially doing the same as the hbox:n{}nobreak, so you're still using it.
            – David Purton
            Dec 18 '18 at 6:33










          • @DavidPurton I added a new version (at the top) using only plain TeX primitives. Not sure if you prefer this one, but it works because of the penalty -5 which coaxes a line break (but not strongly). For example, it still produces the image above, but for #2, if you delete him then Selah jumps up to the same line as the text.
            – whatisit
            Dec 19 '18 at 2:44
















          Thanks. I'll do some experimenting. I don't claim to fully understand the code from the TeXbook, but my use case is simpler in some respects so the code may be able to be simplified.
          – David Purton
          Dec 18 '18 at 5:43




          Thanks. I'll do some experimenting. I don't claim to fully understand the code from the TeXbook, but my use case is simpler in some respects so the code may be able to be simplified.
          – David Purton
          Dec 18 '18 at 5:43












          BTW, using hspace* is essentially doing the same as the hbox:n{}nobreak, so you're still using it.
          – David Purton
          Dec 18 '18 at 6:33




          BTW, using hspace* is essentially doing the same as the hbox:n{}nobreak, so you're still using it.
          – David Purton
          Dec 18 '18 at 6:33












          @DavidPurton I added a new version (at the top) using only plain TeX primitives. Not sure if you prefer this one, but it works because of the penalty -5 which coaxes a line break (but not strongly). For example, it still produces the image above, but for #2, if you delete him then Selah jumps up to the same line as the text.
          – whatisit
          Dec 19 '18 at 2:44




          @DavidPurton I added a new version (at the top) using only plain TeX primitives. Not sure if you prefer this one, but it works because of the penalty -5 which coaxes a line break (but not strongly). For example, it still produces the image above, but for #2, if you delete him then Selah jumps up to the same line as the text.
          – whatisit
          Dec 19 '18 at 2:44


















          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.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • 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%2f466306%2falign-last-word-of-paragraph-to-right-with-raggedright%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

          Aardman Animations

          Are they similar matrix

          “minimization” problem in Euclidean space related to orthonormal basis