Does leavevmode leave any tokens in the input stream

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite












The standard (plain TeX) definition of is



defleavevmodeunhboxvoidb@x


where voidb@x is a permanently empty box. This will force TeX to leave vertical mode, and so is widely used to start horizontal mode material (particularly in LaTeX). Does this definition have any other influence on the processing of input?










share|improve this question

























    up vote
    3
    down vote

    favorite












    The standard (plain TeX) definition of is



    defleavevmodeunhboxvoidb@x


    where voidb@x is a permanently empty box. This will force TeX to leave vertical mode, and so is widely used to start horizontal mode material (particularly in LaTeX). Does this definition have any other influence on the processing of input?










    share|improve this question























      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      The standard (plain TeX) definition of is



      defleavevmodeunhboxvoidb@x


      where voidb@x is a permanently empty box. This will force TeX to leave vertical mode, and so is widely used to start horizontal mode material (particularly in LaTeX). Does this definition have any other influence on the processing of input?










      share|improve this question













      The standard (plain TeX) definition of is



      defleavevmodeunhboxvoidb@x


      where voidb@x is a permanently empty box. This will force TeX to leave vertical mode, and so is widely used to start horizontal mode material (particularly in LaTeX). Does this definition have any other influence on the processing of input?







      tex-core






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 19 mins ago









      Joseph Wright♦

      197k21544864




      197k21544864




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          4
          down vote













          When the standard leavemode is executed in vertical mode, the unhbox primitive switches TeX to horizontal mode. The unhbox token remains in the input stream at that point. This can be seen if we arrange to grab the first token in a paragraph using everypar:



          deftemp#1deftemp#1showtemp
          everypartemp
          leavevmode A
          bye


          which yields



          > temp=macro:
          ->unhbox .


          This could potentially be an issue if some kind of look-ahead is in use. Of course, the unboxed empty box has no 'residual' effect on the vertical list being constructed.




          The standard leavevmode is the best definition with TeX90. However, when e-TeX is available, it is possible to use



          protecteddefleavevmodeifvmodeexpandafterindentfi


          With this indention, TeX executes indent before everypar is inserted. Thus there is nothing 'stray' in the input. (Try the demo above to see this.)



          The reason this needs protected is the behaviour of TeX at the start of an halign. There, TeX will expand normal macros but (probably surprisingly) ifvmode is true. Thus the result would be 'wrong':



          halign#cr leavevmode acr acr
          defleavevmodeifvmodeexpandafterindentfi
          halign#cr leavevmode acr acr
          protecteddefleavevmodeifvmodeexpandafterindentfi
          halign#cr leavevmode acr acr
          bye


          The e-TeX protected mechanism avoids this, making the indent-based leavevmode approach viable.






          share|improve this answer




















            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',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            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%2f454161%2fdoes-leavevmode-leave-any-tokens-in-the-input-stream%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            4
            down vote













            When the standard leavemode is executed in vertical mode, the unhbox primitive switches TeX to horizontal mode. The unhbox token remains in the input stream at that point. This can be seen if we arrange to grab the first token in a paragraph using everypar:



            deftemp#1deftemp#1showtemp
            everypartemp
            leavevmode A
            bye


            which yields



            > temp=macro:
            ->unhbox .


            This could potentially be an issue if some kind of look-ahead is in use. Of course, the unboxed empty box has no 'residual' effect on the vertical list being constructed.




            The standard leavevmode is the best definition with TeX90. However, when e-TeX is available, it is possible to use



            protecteddefleavevmodeifvmodeexpandafterindentfi


            With this indention, TeX executes indent before everypar is inserted. Thus there is nothing 'stray' in the input. (Try the demo above to see this.)



            The reason this needs protected is the behaviour of TeX at the start of an halign. There, TeX will expand normal macros but (probably surprisingly) ifvmode is true. Thus the result would be 'wrong':



            halign#cr leavevmode acr acr
            defleavevmodeifvmodeexpandafterindentfi
            halign#cr leavevmode acr acr
            protecteddefleavevmodeifvmodeexpandafterindentfi
            halign#cr leavevmode acr acr
            bye


            The e-TeX protected mechanism avoids this, making the indent-based leavevmode approach viable.






            share|improve this answer
























              up vote
              4
              down vote













              When the standard leavemode is executed in vertical mode, the unhbox primitive switches TeX to horizontal mode. The unhbox token remains in the input stream at that point. This can be seen if we arrange to grab the first token in a paragraph using everypar:



              deftemp#1deftemp#1showtemp
              everypartemp
              leavevmode A
              bye


              which yields



              > temp=macro:
              ->unhbox .


              This could potentially be an issue if some kind of look-ahead is in use. Of course, the unboxed empty box has no 'residual' effect on the vertical list being constructed.




              The standard leavevmode is the best definition with TeX90. However, when e-TeX is available, it is possible to use



              protecteddefleavevmodeifvmodeexpandafterindentfi


              With this indention, TeX executes indent before everypar is inserted. Thus there is nothing 'stray' in the input. (Try the demo above to see this.)



              The reason this needs protected is the behaviour of TeX at the start of an halign. There, TeX will expand normal macros but (probably surprisingly) ifvmode is true. Thus the result would be 'wrong':



              halign#cr leavevmode acr acr
              defleavevmodeifvmodeexpandafterindentfi
              halign#cr leavevmode acr acr
              protecteddefleavevmodeifvmodeexpandafterindentfi
              halign#cr leavevmode acr acr
              bye


              The e-TeX protected mechanism avoids this, making the indent-based leavevmode approach viable.






              share|improve this answer






















                up vote
                4
                down vote










                up vote
                4
                down vote









                When the standard leavemode is executed in vertical mode, the unhbox primitive switches TeX to horizontal mode. The unhbox token remains in the input stream at that point. This can be seen if we arrange to grab the first token in a paragraph using everypar:



                deftemp#1deftemp#1showtemp
                everypartemp
                leavevmode A
                bye


                which yields



                > temp=macro:
                ->unhbox .


                This could potentially be an issue if some kind of look-ahead is in use. Of course, the unboxed empty box has no 'residual' effect on the vertical list being constructed.




                The standard leavevmode is the best definition with TeX90. However, when e-TeX is available, it is possible to use



                protecteddefleavevmodeifvmodeexpandafterindentfi


                With this indention, TeX executes indent before everypar is inserted. Thus there is nothing 'stray' in the input. (Try the demo above to see this.)



                The reason this needs protected is the behaviour of TeX at the start of an halign. There, TeX will expand normal macros but (probably surprisingly) ifvmode is true. Thus the result would be 'wrong':



                halign#cr leavevmode acr acr
                defleavevmodeifvmodeexpandafterindentfi
                halign#cr leavevmode acr acr
                protecteddefleavevmodeifvmodeexpandafterindentfi
                halign#cr leavevmode acr acr
                bye


                The e-TeX protected mechanism avoids this, making the indent-based leavevmode approach viable.






                share|improve this answer












                When the standard leavemode is executed in vertical mode, the unhbox primitive switches TeX to horizontal mode. The unhbox token remains in the input stream at that point. This can be seen if we arrange to grab the first token in a paragraph using everypar:



                deftemp#1deftemp#1showtemp
                everypartemp
                leavevmode A
                bye


                which yields



                > temp=macro:
                ->unhbox .


                This could potentially be an issue if some kind of look-ahead is in use. Of course, the unboxed empty box has no 'residual' effect on the vertical list being constructed.




                The standard leavevmode is the best definition with TeX90. However, when e-TeX is available, it is possible to use



                protecteddefleavevmodeifvmodeexpandafterindentfi


                With this indention, TeX executes indent before everypar is inserted. Thus there is nothing 'stray' in the input. (Try the demo above to see this.)



                The reason this needs protected is the behaviour of TeX at the start of an halign. There, TeX will expand normal macros but (probably surprisingly) ifvmode is true. Thus the result would be 'wrong':



                halign#cr leavevmode acr acr
                defleavevmodeifvmodeexpandafterindentfi
                halign#cr leavevmode acr acr
                protecteddefleavevmodeifvmodeexpandafterindentfi
                halign#cr leavevmode acr acr
                bye


                The e-TeX protected mechanism avoids this, making the indent-based leavevmode approach viable.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 19 mins ago









                Joseph Wright♦

                197k21544864




                197k21544864



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f454161%2fdoes-leavevmode-leave-any-tokens-in-the-input-stream%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

                    Long meetings (6-7 hours a day): Being “babysat” by supervisor

                    Confectionery