Ellipses & Correct Space Factor












4















I’m trying to use the Unicode ellipsis character (U+2026 ‘…’) in my source files. To this end, I’m looking for an ellipsis macro which I can use with newunicodechar.



The trouble is, I’ve noticed, that the spacefactor is not set correctly around ellipses. This makes solutions like those suggested at Ellipsis with a period/fullstop not work too well.



To illustrate (magnify the results):



documentclass{article}
newcommand*{egap}{kernfontdimen3font} % Taken from the LaTeX definition
begin{document}
dots: \
I.egap.egap. I quad(bad) \
I.egap.egap.@ I quad(good) \
I.egap.egap.egap. I quad(good) \
I.egap.egap.egap.@ I quad(bad)
end{document}


The ellipsis package fixes some issues with uneven spacing, but does not correctly set the space factor. To illustrate:



documentclass{article}
usepackage[xspace]{ellipsis}
newcommand*{egap}{kernfontdimen3font} % For comparison
begin{document}
[ellipsis]: \
I.egap.egap.@ I quad(good, for comparison) \
Itextellipsis I quad(bad) \
Itextellipsis@ I quad(terrible) \
Itextellipsis. I quad(good) \
Itextellipsis.@ I quad(bad)
end{document}


How can I get the spacing correct?










share|improve this question





























    4















    I’m trying to use the Unicode ellipsis character (U+2026 ‘…’) in my source files. To this end, I’m looking for an ellipsis macro which I can use with newunicodechar.



    The trouble is, I’ve noticed, that the spacefactor is not set correctly around ellipses. This makes solutions like those suggested at Ellipsis with a period/fullstop not work too well.



    To illustrate (magnify the results):



    documentclass{article}
    newcommand*{egap}{kernfontdimen3font} % Taken from the LaTeX definition
    begin{document}
    dots: \
    I.egap.egap. I quad(bad) \
    I.egap.egap.@ I quad(good) \
    I.egap.egap.egap. I quad(good) \
    I.egap.egap.egap.@ I quad(bad)
    end{document}


    The ellipsis package fixes some issues with uneven spacing, but does not correctly set the space factor. To illustrate:



    documentclass{article}
    usepackage[xspace]{ellipsis}
    newcommand*{egap}{kernfontdimen3font} % For comparison
    begin{document}
    [ellipsis]: \
    I.egap.egap.@ I quad(good, for comparison) \
    Itextellipsis I quad(bad) \
    Itextellipsis@ I quad(terrible) \
    Itextellipsis. I quad(good) \
    Itextellipsis.@ I quad(bad)
    end{document}


    How can I get the spacing correct?










    share|improve this question



























      4












      4








      4








      I’m trying to use the Unicode ellipsis character (U+2026 ‘…’) in my source files. To this end, I’m looking for an ellipsis macro which I can use with newunicodechar.



      The trouble is, I’ve noticed, that the spacefactor is not set correctly around ellipses. This makes solutions like those suggested at Ellipsis with a period/fullstop not work too well.



      To illustrate (magnify the results):



      documentclass{article}
      newcommand*{egap}{kernfontdimen3font} % Taken from the LaTeX definition
      begin{document}
      dots: \
      I.egap.egap. I quad(bad) \
      I.egap.egap.@ I quad(good) \
      I.egap.egap.egap. I quad(good) \
      I.egap.egap.egap.@ I quad(bad)
      end{document}


      The ellipsis package fixes some issues with uneven spacing, but does not correctly set the space factor. To illustrate:



      documentclass{article}
      usepackage[xspace]{ellipsis}
      newcommand*{egap}{kernfontdimen3font} % For comparison
      begin{document}
      [ellipsis]: \
      I.egap.egap.@ I quad(good, for comparison) \
      Itextellipsis I quad(bad) \
      Itextellipsis@ I quad(terrible) \
      Itextellipsis. I quad(good) \
      Itextellipsis.@ I quad(bad)
      end{document}


      How can I get the spacing correct?










      share|improve this question
















      I’m trying to use the Unicode ellipsis character (U+2026 ‘…’) in my source files. To this end, I’m looking for an ellipsis macro which I can use with newunicodechar.



      The trouble is, I’ve noticed, that the spacefactor is not set correctly around ellipses. This makes solutions like those suggested at Ellipsis with a period/fullstop not work too well.



      To illustrate (magnify the results):



      documentclass{article}
      newcommand*{egap}{kernfontdimen3font} % Taken from the LaTeX definition
      begin{document}
      dots: \
      I.egap.egap. I quad(bad) \
      I.egap.egap.@ I quad(good) \
      I.egap.egap.egap. I quad(good) \
      I.egap.egap.egap.@ I quad(bad)
      end{document}


      The ellipsis package fixes some issues with uneven spacing, but does not correctly set the space factor. To illustrate:



      documentclass{article}
      usepackage[xspace]{ellipsis}
      newcommand*{egap}{kernfontdimen3font} % For comparison
      begin{document}
      [ellipsis]: \
      I.egap.egap.@ I quad(good, for comparison) \
      Itextellipsis I quad(bad) \
      Itextellipsis@ I quad(terrible) \
      Itextellipsis. I quad(good) \
      Itextellipsis.@ I quad(bad)
      end{document}


      How can I get the spacing correct?







      spacing punctuation






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jun 13 '17 at 19:33









      David Carlisle

      493k4111371885




      493k4111371885










      asked Jul 3 '12 at 19:04









      J. C. SalomonJ. C. Salomon

      3,2881536




      3,2881536






















          2 Answers
          2






          active

          oldest

          votes


















          3














          For restricted cases, @ifnextchar is sufficient:



          documentclass{article}
          usepackage[utf8]{inputenc}

          newcommand*{egap}{kernfontdimen3font}
          newcommand*{wordspace}{@space}
          makeatletternewcommand*{elip}{.egap.egap.@ifnextchar.egapwordspace}makeatother
          usepackage{newunicodechar}
          newunicodechar{…}{elip}

          begin{document}
          macro: \
          Ielip I quad(good) \
          Ielip. I quad(good)

          Unicode glyph: \
          I… I quad(good) \
          I…. I quad(good)

          But— \
          Ielip, I quad(bad) \
          Ielip! I quad(bad) \
          Ielip? I quad(bad)

          end{document}


          A fuller version requires a generalization of @ifnextchar. Adapting egreg’s answer to a related question leads toward such a generalization:



          documentclass{article}
          usepackage[utf8]{inputenc}

          usepackage{xparse}
          ExplSyntaxOn
          NewDocumentCommand{elip}{ } { elip_main: }
          NewDocumentCommand{addtoelipexceptions}{m}
          {
          tl_gput_right:Nn g_elip_exceptions_tl { #1 }
          }
          cs_new_protected:Npn elip_gap
          {
          kernfontdimen3font
          }
          cs_new_protected:Npn elip_main:
          {
          .elip_gap.elip_gap.
          bool_set_true:N l_elip_apply_bool
          peek_catcode_ignore_spaces:NF c_space_token { elip_check: }
          }
          cs_new_protected:Npn elip_check:
          {
          tl_map_inline:Nn g_elip_exceptions_tl
          {
          token_if_eq_charcode:NNT ##1 l_peek_token
          {bool_set_false:N l_elip_apply_bool prg_map_break: }
          }
          bool_if:NTF l_elip_apply_bool
          { @~ }
          { elip_gap }
          }
          tl_new:N g_elip_exceptions_tl
          ExplSyntaxOff

          usepackage{newunicodechar}
          newunicodechar{…}{elip}

          begin{document}
          macro: \
          Ielip I quad(good) \
          Ielip. I quad(good)

          Unicode glyph: \
          I… I quad(good) \
          I…. I quad(good)

          But— \
          I…, I quad(bad) \
          I…! I quad(bad) \
          I…? I quad(bad)

          addtoelipexceptions{,.!?}
          Now: \
          I…, I quad(good) \
          I…! I quad(good) \
          I…? I quad(good)
          end{document}


          (Improvements to expl3 style, or an actual generalized @ifnextchar, would be welcome.)






          share|improve this answer


























          • Yes, nesting @ifnextchar invocations will also work, but loops are better & more configurable.

            – J. C. Salomon
            Jul 4 '12 at 1:50



















          0














          Returning to this question…



          The ellipses package exposes a hook:



          RequirePackage{ellipsis}
          renewcommand{ellipsis@after}{@}
          newunicodechar{…}{textellipsis}


          does the trick.





          share























            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%2f62111%2fellipses-correct-space-factor%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            3














            For restricted cases, @ifnextchar is sufficient:



            documentclass{article}
            usepackage[utf8]{inputenc}

            newcommand*{egap}{kernfontdimen3font}
            newcommand*{wordspace}{@space}
            makeatletternewcommand*{elip}{.egap.egap.@ifnextchar.egapwordspace}makeatother
            usepackage{newunicodechar}
            newunicodechar{…}{elip}

            begin{document}
            macro: \
            Ielip I quad(good) \
            Ielip. I quad(good)

            Unicode glyph: \
            I… I quad(good) \
            I…. I quad(good)

            But— \
            Ielip, I quad(bad) \
            Ielip! I quad(bad) \
            Ielip? I quad(bad)

            end{document}


            A fuller version requires a generalization of @ifnextchar. Adapting egreg’s answer to a related question leads toward such a generalization:



            documentclass{article}
            usepackage[utf8]{inputenc}

            usepackage{xparse}
            ExplSyntaxOn
            NewDocumentCommand{elip}{ } { elip_main: }
            NewDocumentCommand{addtoelipexceptions}{m}
            {
            tl_gput_right:Nn g_elip_exceptions_tl { #1 }
            }
            cs_new_protected:Npn elip_gap
            {
            kernfontdimen3font
            }
            cs_new_protected:Npn elip_main:
            {
            .elip_gap.elip_gap.
            bool_set_true:N l_elip_apply_bool
            peek_catcode_ignore_spaces:NF c_space_token { elip_check: }
            }
            cs_new_protected:Npn elip_check:
            {
            tl_map_inline:Nn g_elip_exceptions_tl
            {
            token_if_eq_charcode:NNT ##1 l_peek_token
            {bool_set_false:N l_elip_apply_bool prg_map_break: }
            }
            bool_if:NTF l_elip_apply_bool
            { @~ }
            { elip_gap }
            }
            tl_new:N g_elip_exceptions_tl
            ExplSyntaxOff

            usepackage{newunicodechar}
            newunicodechar{…}{elip}

            begin{document}
            macro: \
            Ielip I quad(good) \
            Ielip. I quad(good)

            Unicode glyph: \
            I… I quad(good) \
            I…. I quad(good)

            But— \
            I…, I quad(bad) \
            I…! I quad(bad) \
            I…? I quad(bad)

            addtoelipexceptions{,.!?}
            Now: \
            I…, I quad(good) \
            I…! I quad(good) \
            I…? I quad(good)
            end{document}


            (Improvements to expl3 style, or an actual generalized @ifnextchar, would be welcome.)






            share|improve this answer


























            • Yes, nesting @ifnextchar invocations will also work, but loops are better & more configurable.

              – J. C. Salomon
              Jul 4 '12 at 1:50
















            3














            For restricted cases, @ifnextchar is sufficient:



            documentclass{article}
            usepackage[utf8]{inputenc}

            newcommand*{egap}{kernfontdimen3font}
            newcommand*{wordspace}{@space}
            makeatletternewcommand*{elip}{.egap.egap.@ifnextchar.egapwordspace}makeatother
            usepackage{newunicodechar}
            newunicodechar{…}{elip}

            begin{document}
            macro: \
            Ielip I quad(good) \
            Ielip. I quad(good)

            Unicode glyph: \
            I… I quad(good) \
            I…. I quad(good)

            But— \
            Ielip, I quad(bad) \
            Ielip! I quad(bad) \
            Ielip? I quad(bad)

            end{document}


            A fuller version requires a generalization of @ifnextchar. Adapting egreg’s answer to a related question leads toward such a generalization:



            documentclass{article}
            usepackage[utf8]{inputenc}

            usepackage{xparse}
            ExplSyntaxOn
            NewDocumentCommand{elip}{ } { elip_main: }
            NewDocumentCommand{addtoelipexceptions}{m}
            {
            tl_gput_right:Nn g_elip_exceptions_tl { #1 }
            }
            cs_new_protected:Npn elip_gap
            {
            kernfontdimen3font
            }
            cs_new_protected:Npn elip_main:
            {
            .elip_gap.elip_gap.
            bool_set_true:N l_elip_apply_bool
            peek_catcode_ignore_spaces:NF c_space_token { elip_check: }
            }
            cs_new_protected:Npn elip_check:
            {
            tl_map_inline:Nn g_elip_exceptions_tl
            {
            token_if_eq_charcode:NNT ##1 l_peek_token
            {bool_set_false:N l_elip_apply_bool prg_map_break: }
            }
            bool_if:NTF l_elip_apply_bool
            { @~ }
            { elip_gap }
            }
            tl_new:N g_elip_exceptions_tl
            ExplSyntaxOff

            usepackage{newunicodechar}
            newunicodechar{…}{elip}

            begin{document}
            macro: \
            Ielip I quad(good) \
            Ielip. I quad(good)

            Unicode glyph: \
            I… I quad(good) \
            I…. I quad(good)

            But— \
            I…, I quad(bad) \
            I…! I quad(bad) \
            I…? I quad(bad)

            addtoelipexceptions{,.!?}
            Now: \
            I…, I quad(good) \
            I…! I quad(good) \
            I…? I quad(good)
            end{document}


            (Improvements to expl3 style, or an actual generalized @ifnextchar, would be welcome.)






            share|improve this answer


























            • Yes, nesting @ifnextchar invocations will also work, but loops are better & more configurable.

              – J. C. Salomon
              Jul 4 '12 at 1:50














            3












            3








            3







            For restricted cases, @ifnextchar is sufficient:



            documentclass{article}
            usepackage[utf8]{inputenc}

            newcommand*{egap}{kernfontdimen3font}
            newcommand*{wordspace}{@space}
            makeatletternewcommand*{elip}{.egap.egap.@ifnextchar.egapwordspace}makeatother
            usepackage{newunicodechar}
            newunicodechar{…}{elip}

            begin{document}
            macro: \
            Ielip I quad(good) \
            Ielip. I quad(good)

            Unicode glyph: \
            I… I quad(good) \
            I…. I quad(good)

            But— \
            Ielip, I quad(bad) \
            Ielip! I quad(bad) \
            Ielip? I quad(bad)

            end{document}


            A fuller version requires a generalization of @ifnextchar. Adapting egreg’s answer to a related question leads toward such a generalization:



            documentclass{article}
            usepackage[utf8]{inputenc}

            usepackage{xparse}
            ExplSyntaxOn
            NewDocumentCommand{elip}{ } { elip_main: }
            NewDocumentCommand{addtoelipexceptions}{m}
            {
            tl_gput_right:Nn g_elip_exceptions_tl { #1 }
            }
            cs_new_protected:Npn elip_gap
            {
            kernfontdimen3font
            }
            cs_new_protected:Npn elip_main:
            {
            .elip_gap.elip_gap.
            bool_set_true:N l_elip_apply_bool
            peek_catcode_ignore_spaces:NF c_space_token { elip_check: }
            }
            cs_new_protected:Npn elip_check:
            {
            tl_map_inline:Nn g_elip_exceptions_tl
            {
            token_if_eq_charcode:NNT ##1 l_peek_token
            {bool_set_false:N l_elip_apply_bool prg_map_break: }
            }
            bool_if:NTF l_elip_apply_bool
            { @~ }
            { elip_gap }
            }
            tl_new:N g_elip_exceptions_tl
            ExplSyntaxOff

            usepackage{newunicodechar}
            newunicodechar{…}{elip}

            begin{document}
            macro: \
            Ielip I quad(good) \
            Ielip. I quad(good)

            Unicode glyph: \
            I… I quad(good) \
            I…. I quad(good)

            But— \
            I…, I quad(bad) \
            I…! I quad(bad) \
            I…? I quad(bad)

            addtoelipexceptions{,.!?}
            Now: \
            I…, I quad(good) \
            I…! I quad(good) \
            I…? I quad(good)
            end{document}


            (Improvements to expl3 style, or an actual generalized @ifnextchar, would be welcome.)






            share|improve this answer















            For restricted cases, @ifnextchar is sufficient:



            documentclass{article}
            usepackage[utf8]{inputenc}

            newcommand*{egap}{kernfontdimen3font}
            newcommand*{wordspace}{@space}
            makeatletternewcommand*{elip}{.egap.egap.@ifnextchar.egapwordspace}makeatother
            usepackage{newunicodechar}
            newunicodechar{…}{elip}

            begin{document}
            macro: \
            Ielip I quad(good) \
            Ielip. I quad(good)

            Unicode glyph: \
            I… I quad(good) \
            I…. I quad(good)

            But— \
            Ielip, I quad(bad) \
            Ielip! I quad(bad) \
            Ielip? I quad(bad)

            end{document}


            A fuller version requires a generalization of @ifnextchar. Adapting egreg’s answer to a related question leads toward such a generalization:



            documentclass{article}
            usepackage[utf8]{inputenc}

            usepackage{xparse}
            ExplSyntaxOn
            NewDocumentCommand{elip}{ } { elip_main: }
            NewDocumentCommand{addtoelipexceptions}{m}
            {
            tl_gput_right:Nn g_elip_exceptions_tl { #1 }
            }
            cs_new_protected:Npn elip_gap
            {
            kernfontdimen3font
            }
            cs_new_protected:Npn elip_main:
            {
            .elip_gap.elip_gap.
            bool_set_true:N l_elip_apply_bool
            peek_catcode_ignore_spaces:NF c_space_token { elip_check: }
            }
            cs_new_protected:Npn elip_check:
            {
            tl_map_inline:Nn g_elip_exceptions_tl
            {
            token_if_eq_charcode:NNT ##1 l_peek_token
            {bool_set_false:N l_elip_apply_bool prg_map_break: }
            }
            bool_if:NTF l_elip_apply_bool
            { @~ }
            { elip_gap }
            }
            tl_new:N g_elip_exceptions_tl
            ExplSyntaxOff

            usepackage{newunicodechar}
            newunicodechar{…}{elip}

            begin{document}
            macro: \
            Ielip I quad(good) \
            Ielip. I quad(good)

            Unicode glyph: \
            I… I quad(good) \
            I…. I quad(good)

            But— \
            I…, I quad(bad) \
            I…! I quad(bad) \
            I…? I quad(bad)

            addtoelipexceptions{,.!?}
            Now: \
            I…, I quad(good) \
            I…! I quad(good) \
            I…? I quad(good)
            end{document}


            (Improvements to expl3 style, or an actual generalized @ifnextchar, would be welcome.)







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jun 11 '17 at 18:01









            David Carlisle

            493k4111371885




            493k4111371885










            answered Jul 3 '12 at 19:04









            J. C. SalomonJ. C. Salomon

            3,2881536




            3,2881536













            • Yes, nesting @ifnextchar invocations will also work, but loops are better & more configurable.

              – J. C. Salomon
              Jul 4 '12 at 1:50



















            • Yes, nesting @ifnextchar invocations will also work, but loops are better & more configurable.

              – J. C. Salomon
              Jul 4 '12 at 1:50

















            Yes, nesting @ifnextchar invocations will also work, but loops are better & more configurable.

            – J. C. Salomon
            Jul 4 '12 at 1:50





            Yes, nesting @ifnextchar invocations will also work, but loops are better & more configurable.

            – J. C. Salomon
            Jul 4 '12 at 1:50











            0














            Returning to this question…



            The ellipses package exposes a hook:



            RequirePackage{ellipsis}
            renewcommand{ellipsis@after}{@}
            newunicodechar{…}{textellipsis}


            does the trick.





            share




























              0














              Returning to this question…



              The ellipses package exposes a hook:



              RequirePackage{ellipsis}
              renewcommand{ellipsis@after}{@}
              newunicodechar{…}{textellipsis}


              does the trick.





              share


























                0












                0








                0







                Returning to this question…



                The ellipses package exposes a hook:



                RequirePackage{ellipsis}
                renewcommand{ellipsis@after}{@}
                newunicodechar{…}{textellipsis}


                does the trick.





                share













                Returning to this question…



                The ellipses package exposes a hook:



                RequirePackage{ellipsis}
                renewcommand{ellipsis@after}{@}
                newunicodechar{…}{textellipsis}


                does the trick.






                share











                share


                share










                answered 2 mins ago









                J. C. SalomonJ. C. Salomon

                3,2881536




                3,2881536






























                    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%2f62111%2fellipses-correct-space-factor%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

                    サソリ

                    広島県道265号伴広島線

                    Setup Asymptote in Texstudio