etoolbox: AtBeginEnvironment is not At Begin EnvironmentRemove space after figure and before textSpacing...

Why is there a need to modify system call tables in linux?

Can a helicopter mask itself from Radar?

Preserving culinary oils

Why does the UK have more political parties than the US?

Can a wire having a 610-670 THz (frequency of blue light) AC frequency supply, generate blue light?

Is there a rule that prohibits us from using 2 possessives in a row?

Could I be denied entry into Ireland due to medical and police situations during a previous UK visit?

How was Apollo supposed to rendezvous in the case of a lunar abort?

If a problem only occurs randomly once in every N times on average, how many tests do I have to perform to be certain that it's now fixed?

What was this black-and-white film set in the Arctic or Antarctic where the monster/alien gets fried in the end?

Is a hash a zero-knowledge proof?

Points within polygons in different projections

What is the indigenous Russian word for a wild boar?

If I create magical darkness with the Silent Image spell, can I see through it if I have the Devil's Sight warlock invocation?

Possible nonclassical ion from a bicyclic system

How did early x86 BIOS programmers manage to program full blown TUIs given very few bytes of ROM/EPROM?

How can I offer a test ride while selling a bike?

Understanding STM32 datasheet regarding decoupling capacitors

How crucial is a waifu game storyline?

Can a rogue effectively triple their speed by combining Dash and Ready?

Intuition behind eigenvalues of an adjacency matrix

Windows 10 Programs start without visual Interface

The qvolume of an integer

Asking bank to reduce APR instead of increasing credit limit



etoolbox: AtBeginEnvironment is not At Begin Environment


Remove space after figure and before textSpacing around table and figure environmentsmultiple lists in etoolboxPhantom and etoolbox iftogglePackage etoolbox Warning: Patching 'begin' failed!Hide an environment and show it later in the documentetoolbox conflict with bm packageProblem changing spacing for equation environmentquestion of ifstrequal in etoolboxImage Not Found in Command with EtoolboxEnd mark switching fails because @ifnextchar's behavior in an environment hook is not as naively expectedObeylines and gappto from etoolbox













6















I tried the following MWE:



documentclass{article}
usepackage{etoolbox}

AtBeginEnvironment{table}{AtBeginEnvironmentpar}
AtEndEnvironment{table}{AtEndEnvironmentpar}
BeforeBeginEnvironment{table}{BeforeBeginEnvironmentpar}
AfterEndEnvironment{table}{AfterEndEnvironmentpar}

begin{document}
Text beforepar
begin{table} [t]%
Table textpar
end{table}
Text afterpar
end{document}


and got the following result:



Table text
AtEndEnvironment
Text before
BeforeBeginEnvironment
AtBeginEnvironment
AfterEndEnvironment
Text after


I was expecting AtBeginEnvironment to travel to the top of the page together with the float.
Here is what the manual has to say on the matter:



AtBeginEnvironment{<environment>}{<code>}
Appends arbitrary <code> to a hook executed by the begin command
at the beginning of a given <environment>, immediately before
<environment>, inside the group opened by begin.


I do not know what happens inside an environment definition; I guess it declares some special commands called <environment> (e.g. table) and end<environment> (e.g. endtable).



But in this case, shouldn't it be immediately after <environment>, in order to be a complement to AtEndEnvironment just as BeforeBeginEnvironment is a complement to AfterEndEnvironment?



Anyway, how can I add code to the beginning of an environment? I'm trying to set a certain font style for all tables, and AtBeginEnvironment{table}{small} does not work. Also I guess this behavior makes this answer incorrect, because addvspace would stay at the point of declaration of the figure instead of moving together with it.










share|improve this question





























    6















    I tried the following MWE:



    documentclass{article}
    usepackage{etoolbox}

    AtBeginEnvironment{table}{AtBeginEnvironmentpar}
    AtEndEnvironment{table}{AtEndEnvironmentpar}
    BeforeBeginEnvironment{table}{BeforeBeginEnvironmentpar}
    AfterEndEnvironment{table}{AfterEndEnvironmentpar}

    begin{document}
    Text beforepar
    begin{table} [t]%
    Table textpar
    end{table}
    Text afterpar
    end{document}


    and got the following result:



    Table text
    AtEndEnvironment
    Text before
    BeforeBeginEnvironment
    AtBeginEnvironment
    AfterEndEnvironment
    Text after


    I was expecting AtBeginEnvironment to travel to the top of the page together with the float.
    Here is what the manual has to say on the matter:



    AtBeginEnvironment{<environment>}{<code>}
    Appends arbitrary <code> to a hook executed by the begin command
    at the beginning of a given <environment>, immediately before
    <environment>, inside the group opened by begin.


    I do not know what happens inside an environment definition; I guess it declares some special commands called <environment> (e.g. table) and end<environment> (e.g. endtable).



    But in this case, shouldn't it be immediately after <environment>, in order to be a complement to AtEndEnvironment just as BeforeBeginEnvironment is a complement to AfterEndEnvironment?



    Anyway, how can I add code to the beginning of an environment? I'm trying to set a certain font style for all tables, and AtBeginEnvironment{table}{small} does not work. Also I guess this behavior makes this answer incorrect, because addvspace would stay at the point of declaration of the figure instead of moving together with it.










    share|improve this question



























      6












      6








      6








      I tried the following MWE:



      documentclass{article}
      usepackage{etoolbox}

      AtBeginEnvironment{table}{AtBeginEnvironmentpar}
      AtEndEnvironment{table}{AtEndEnvironmentpar}
      BeforeBeginEnvironment{table}{BeforeBeginEnvironmentpar}
      AfterEndEnvironment{table}{AfterEndEnvironmentpar}

      begin{document}
      Text beforepar
      begin{table} [t]%
      Table textpar
      end{table}
      Text afterpar
      end{document}


      and got the following result:



      Table text
      AtEndEnvironment
      Text before
      BeforeBeginEnvironment
      AtBeginEnvironment
      AfterEndEnvironment
      Text after


      I was expecting AtBeginEnvironment to travel to the top of the page together with the float.
      Here is what the manual has to say on the matter:



      AtBeginEnvironment{<environment>}{<code>}
      Appends arbitrary <code> to a hook executed by the begin command
      at the beginning of a given <environment>, immediately before
      <environment>, inside the group opened by begin.


      I do not know what happens inside an environment definition; I guess it declares some special commands called <environment> (e.g. table) and end<environment> (e.g. endtable).



      But in this case, shouldn't it be immediately after <environment>, in order to be a complement to AtEndEnvironment just as BeforeBeginEnvironment is a complement to AfterEndEnvironment?



      Anyway, how can I add code to the beginning of an environment? I'm trying to set a certain font style for all tables, and AtBeginEnvironment{table}{small} does not work. Also I guess this behavior makes this answer incorrect, because addvspace would stay at the point of declaration of the figure instead of moving together with it.










      share|improve this question
















      I tried the following MWE:



      documentclass{article}
      usepackage{etoolbox}

      AtBeginEnvironment{table}{AtBeginEnvironmentpar}
      AtEndEnvironment{table}{AtEndEnvironmentpar}
      BeforeBeginEnvironment{table}{BeforeBeginEnvironmentpar}
      AfterEndEnvironment{table}{AfterEndEnvironmentpar}

      begin{document}
      Text beforepar
      begin{table} [t]%
      Table textpar
      end{table}
      Text afterpar
      end{document}


      and got the following result:



      Table text
      AtEndEnvironment
      Text before
      BeforeBeginEnvironment
      AtBeginEnvironment
      AfterEndEnvironment
      Text after


      I was expecting AtBeginEnvironment to travel to the top of the page together with the float.
      Here is what the manual has to say on the matter:



      AtBeginEnvironment{<environment>}{<code>}
      Appends arbitrary <code> to a hook executed by the begin command
      at the beginning of a given <environment>, immediately before
      <environment>, inside the group opened by begin.


      I do not know what happens inside an environment definition; I guess it declares some special commands called <environment> (e.g. table) and end<environment> (e.g. endtable).



      But in this case, shouldn't it be immediately after <environment>, in order to be a complement to AtEndEnvironment just as BeforeBeginEnvironment is a complement to AfterEndEnvironment?



      Anyway, how can I add code to the beginning of an environment? I'm trying to set a certain font style for all tables, and AtBeginEnvironment{table}{small} does not work. Also I guess this behavior makes this answer incorrect, because addvspace would stay at the point of declaration of the figure instead of moving together with it.







      etoolbox






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 9 hours ago







      ScumCoder

















      asked 9 hours ago









      ScumCoderScumCoder

      630512




      630512






















          1 Answer
          1






          active

          oldest

          votes


















          8














          The etoolbox package redefines begin so that





          1. @beforebegin@<envname>@hook is executed

          2. the usual bookkeeping is performed (setting @currenvir, for instance)


          3. @begin@<envname>@hook is executed
            1 a group is started

          4. the macro <envname> is executed


          Thus what you get is



          @beforebegin@table@hook
          <bookkeeping>
          @begin@table@hook
          begingroup
          table


          The macro table is responsible for starting the creation of a float and expands to @float{table}.



          Thus the tokens AtBeginEnvironmentpar and BeforeBeginEnvironmentpar are seen and the paragraphs are typeset before the float is started.



          To the contrary, end is redefined to execute the AtEndEnvironment tokens before end<envname> is executed.



          This should explain the output you get.



          There is a hook for doing things when the float has already begun and is @floatboxreset.



          I would be wary of using the hooks for adding text: they're meant for additional setup.






          share|improve this answer
























          • @begin@table@hook isn't inside the group?

            – touhami
            9 hours ago











          • Thank you. > I would be wary of using the hooks for adding text: they're meant for additional setup. I'm wary too, I just used it to see what goes where. > There is a hook for doing things when the float has already begun and is @floatboxreset. That’s helpful, but alas, it does not allow to set different settings for different float types.

            – ScumCoder
            9 hours ago











          • Also, I must add that I ended up using setfloatadjustment command from memoir, on which I stumbled upon when I read your answer and started digging the @floatboxreset.

            – ScumCoder
            8 hours ago











          • @ScumCoder you can put float-type specific code in @floatboxreset you just need to test @captype

            – David Carlisle
            8 hours ago











          • @DavidCarlisle I'm afraid this is a bit too hardcore for me yet, I'll just settle for something more philistine for the time being :)

            – ScumCoder
            8 hours ago












          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%2f493087%2fetoolbox-atbeginenvironment-is-not-at-begin-environment%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









          8














          The etoolbox package redefines begin so that





          1. @beforebegin@<envname>@hook is executed

          2. the usual bookkeeping is performed (setting @currenvir, for instance)


          3. @begin@<envname>@hook is executed
            1 a group is started

          4. the macro <envname> is executed


          Thus what you get is



          @beforebegin@table@hook
          <bookkeeping>
          @begin@table@hook
          begingroup
          table


          The macro table is responsible for starting the creation of a float and expands to @float{table}.



          Thus the tokens AtBeginEnvironmentpar and BeforeBeginEnvironmentpar are seen and the paragraphs are typeset before the float is started.



          To the contrary, end is redefined to execute the AtEndEnvironment tokens before end<envname> is executed.



          This should explain the output you get.



          There is a hook for doing things when the float has already begun and is @floatboxreset.



          I would be wary of using the hooks for adding text: they're meant for additional setup.






          share|improve this answer
























          • @begin@table@hook isn't inside the group?

            – touhami
            9 hours ago











          • Thank you. > I would be wary of using the hooks for adding text: they're meant for additional setup. I'm wary too, I just used it to see what goes where. > There is a hook for doing things when the float has already begun and is @floatboxreset. That’s helpful, but alas, it does not allow to set different settings for different float types.

            – ScumCoder
            9 hours ago











          • Also, I must add that I ended up using setfloatadjustment command from memoir, on which I stumbled upon when I read your answer and started digging the @floatboxreset.

            – ScumCoder
            8 hours ago











          • @ScumCoder you can put float-type specific code in @floatboxreset you just need to test @captype

            – David Carlisle
            8 hours ago











          • @DavidCarlisle I'm afraid this is a bit too hardcore for me yet, I'll just settle for something more philistine for the time being :)

            – ScumCoder
            8 hours ago
















          8














          The etoolbox package redefines begin so that





          1. @beforebegin@<envname>@hook is executed

          2. the usual bookkeeping is performed (setting @currenvir, for instance)


          3. @begin@<envname>@hook is executed
            1 a group is started

          4. the macro <envname> is executed


          Thus what you get is



          @beforebegin@table@hook
          <bookkeeping>
          @begin@table@hook
          begingroup
          table


          The macro table is responsible for starting the creation of a float and expands to @float{table}.



          Thus the tokens AtBeginEnvironmentpar and BeforeBeginEnvironmentpar are seen and the paragraphs are typeset before the float is started.



          To the contrary, end is redefined to execute the AtEndEnvironment tokens before end<envname> is executed.



          This should explain the output you get.



          There is a hook for doing things when the float has already begun and is @floatboxreset.



          I would be wary of using the hooks for adding text: they're meant for additional setup.






          share|improve this answer
























          • @begin@table@hook isn't inside the group?

            – touhami
            9 hours ago











          • Thank you. > I would be wary of using the hooks for adding text: they're meant for additional setup. I'm wary too, I just used it to see what goes where. > There is a hook for doing things when the float has already begun and is @floatboxreset. That’s helpful, but alas, it does not allow to set different settings for different float types.

            – ScumCoder
            9 hours ago











          • Also, I must add that I ended up using setfloatadjustment command from memoir, on which I stumbled upon when I read your answer and started digging the @floatboxreset.

            – ScumCoder
            8 hours ago











          • @ScumCoder you can put float-type specific code in @floatboxreset you just need to test @captype

            – David Carlisle
            8 hours ago











          • @DavidCarlisle I'm afraid this is a bit too hardcore for me yet, I'll just settle for something more philistine for the time being :)

            – ScumCoder
            8 hours ago














          8












          8








          8







          The etoolbox package redefines begin so that





          1. @beforebegin@<envname>@hook is executed

          2. the usual bookkeeping is performed (setting @currenvir, for instance)


          3. @begin@<envname>@hook is executed
            1 a group is started

          4. the macro <envname> is executed


          Thus what you get is



          @beforebegin@table@hook
          <bookkeeping>
          @begin@table@hook
          begingroup
          table


          The macro table is responsible for starting the creation of a float and expands to @float{table}.



          Thus the tokens AtBeginEnvironmentpar and BeforeBeginEnvironmentpar are seen and the paragraphs are typeset before the float is started.



          To the contrary, end is redefined to execute the AtEndEnvironment tokens before end<envname> is executed.



          This should explain the output you get.



          There is a hook for doing things when the float has already begun and is @floatboxreset.



          I would be wary of using the hooks for adding text: they're meant for additional setup.






          share|improve this answer













          The etoolbox package redefines begin so that





          1. @beforebegin@<envname>@hook is executed

          2. the usual bookkeeping is performed (setting @currenvir, for instance)


          3. @begin@<envname>@hook is executed
            1 a group is started

          4. the macro <envname> is executed


          Thus what you get is



          @beforebegin@table@hook
          <bookkeeping>
          @begin@table@hook
          begingroup
          table


          The macro table is responsible for starting the creation of a float and expands to @float{table}.



          Thus the tokens AtBeginEnvironmentpar and BeforeBeginEnvironmentpar are seen and the paragraphs are typeset before the float is started.



          To the contrary, end is redefined to execute the AtEndEnvironment tokens before end<envname> is executed.



          This should explain the output you get.



          There is a hook for doing things when the float has already begun and is @floatboxreset.



          I would be wary of using the hooks for adding text: they're meant for additional setup.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 9 hours ago









          egregegreg

          745k8919493288




          745k8919493288













          • @begin@table@hook isn't inside the group?

            – touhami
            9 hours ago











          • Thank you. > I would be wary of using the hooks for adding text: they're meant for additional setup. I'm wary too, I just used it to see what goes where. > There is a hook for doing things when the float has already begun and is @floatboxreset. That’s helpful, but alas, it does not allow to set different settings for different float types.

            – ScumCoder
            9 hours ago











          • Also, I must add that I ended up using setfloatadjustment command from memoir, on which I stumbled upon when I read your answer and started digging the @floatboxreset.

            – ScumCoder
            8 hours ago











          • @ScumCoder you can put float-type specific code in @floatboxreset you just need to test @captype

            – David Carlisle
            8 hours ago











          • @DavidCarlisle I'm afraid this is a bit too hardcore for me yet, I'll just settle for something more philistine for the time being :)

            – ScumCoder
            8 hours ago



















          • @begin@table@hook isn't inside the group?

            – touhami
            9 hours ago











          • Thank you. > I would be wary of using the hooks for adding text: they're meant for additional setup. I'm wary too, I just used it to see what goes where. > There is a hook for doing things when the float has already begun and is @floatboxreset. That’s helpful, but alas, it does not allow to set different settings for different float types.

            – ScumCoder
            9 hours ago











          • Also, I must add that I ended up using setfloatadjustment command from memoir, on which I stumbled upon when I read your answer and started digging the @floatboxreset.

            – ScumCoder
            8 hours ago











          • @ScumCoder you can put float-type specific code in @floatboxreset you just need to test @captype

            – David Carlisle
            8 hours ago











          • @DavidCarlisle I'm afraid this is a bit too hardcore for me yet, I'll just settle for something more philistine for the time being :)

            – ScumCoder
            8 hours ago

















          @begin@table@hook isn't inside the group?

          – touhami
          9 hours ago





          @begin@table@hook isn't inside the group?

          – touhami
          9 hours ago













          Thank you. > I would be wary of using the hooks for adding text: they're meant for additional setup. I'm wary too, I just used it to see what goes where. > There is a hook for doing things when the float has already begun and is @floatboxreset. That’s helpful, but alas, it does not allow to set different settings for different float types.

          – ScumCoder
          9 hours ago





          Thank you. > I would be wary of using the hooks for adding text: they're meant for additional setup. I'm wary too, I just used it to see what goes where. > There is a hook for doing things when the float has already begun and is @floatboxreset. That’s helpful, but alas, it does not allow to set different settings for different float types.

          – ScumCoder
          9 hours ago













          Also, I must add that I ended up using setfloatadjustment command from memoir, on which I stumbled upon when I read your answer and started digging the @floatboxreset.

          – ScumCoder
          8 hours ago





          Also, I must add that I ended up using setfloatadjustment command from memoir, on which I stumbled upon when I read your answer and started digging the @floatboxreset.

          – ScumCoder
          8 hours ago













          @ScumCoder you can put float-type specific code in @floatboxreset you just need to test @captype

          – David Carlisle
          8 hours ago





          @ScumCoder you can put float-type specific code in @floatboxreset you just need to test @captype

          – David Carlisle
          8 hours ago













          @DavidCarlisle I'm afraid this is a bit too hardcore for me yet, I'll just settle for something more philistine for the time being :)

          – ScumCoder
          8 hours ago





          @DavidCarlisle I'm afraid this is a bit too hardcore for me yet, I'll just settle for something more philistine for the time being :)

          – ScumCoder
          8 hours ago


















          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%2f493087%2fetoolbox-atbeginenvironment-is-not-at-begin-environment%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

          Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

          Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

          Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...