Expand def in write18What are immediate & write18 and how does one use them?how to escape special chars in write18?How do you detect restricted write18 supportHow to invoke write18pdflatex “defparam…inputfilename”?write18 encodingGet return value of `write18`Postprocess pdf with write18How to force-expand a def for in@?Get write18 to accept / expand command

Meaning of words заштырить and отштырить

When does The Truman Show take place?

Polar contour plot in Mathematica?

Earliest evidence of objects intended for future archaeologists?

How best to join tables, which have different lengths on the same column values which exist in both tables?

Can 'in-' mean both 'in' and 'no'?

My father gets angry everytime I pass Salam, that means I should stop saying Salam when he's around?

Are unaudited server logs admissible in a court of law?

Rotate List by K places

Is there a commercial liquid with refractive index greater than n=2?

Do predators tend to have vertical slit pupils versus horizontal for prey animals?

Unsolved Problems due to Lack of Computational Power

Why do balloons get cold when they deflate?

Why don't politicians push for fossil fuel reduction by pointing out their scarcity?

How do we test and determine if a USB cable+connector is version 2, 3.0 or 3.1?

Installing the original OS X version onto a Mac?

Best model for precedence constraints within scheduling problem

Why is su world executable?

Number of matrices with bounded products of rows and columns

How to translate 脑袋短路 into English?

Eric Andre had a dream

Is there a way to make the "o" keypress of other-window <C-x><C-o> repeatable?

Adding things to bunches of things vs multiplication

Repurpose telephone line to ethernet



Expand def in write18


What are immediate & write18 and how does one use them?how to escape special chars in write18?How do you detect restricted write18 supportHow to invoke write18pdflatex “defparam…inputfilename”?write18 encodingGet return value of `write18`Postprocess pdf with write18How to force-expand a def for in@?Get write18 to accept / expand command






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I have defined the following command:



newcommandformatcommand[1]
deftemp#1
defsifxtempempty emptyelse not emptyfi
echo "s"



This works correctly:



formatcommand
formatcommand


sample



However, when using the above command inside write18,



immediatewrite18formatcommand


the defs seem to not be expanding, since I'm getting def is not an executable..., meaning that write18 sent the body of formatcommand without expanding it to the command line. How can this be fixed?



MWE



documentclass[border=1cm]standalone


begindocument

newcommandformatcommand[1]
deftemp#1
defsifxtempempty emptyelse not emptyfi
echo "s"


formatcommand
formatcommand

immediatewrite18formatcommand

enddocument









share|improve this question






























    2















    I have defined the following command:



    newcommandformatcommand[1]
    deftemp#1
    defsifxtempempty emptyelse not emptyfi
    echo "s"



    This works correctly:



    formatcommand
    formatcommand


    sample



    However, when using the above command inside write18,



    immediatewrite18formatcommand


    the defs seem to not be expanding, since I'm getting def is not an executable..., meaning that write18 sent the body of formatcommand without expanding it to the command line. How can this be fixed?



    MWE



    documentclass[border=1cm]standalone


    begindocument

    newcommandformatcommand[1]
    deftemp#1
    defsifxtempempty emptyelse not emptyfi
    echo "s"


    formatcommand
    formatcommand

    immediatewrite18formatcommand

    enddocument









    share|improve this question


























      2












      2








      2


      1






      I have defined the following command:



      newcommandformatcommand[1]
      deftemp#1
      defsifxtempempty emptyelse not emptyfi
      echo "s"



      This works correctly:



      formatcommand
      formatcommand


      sample



      However, when using the above command inside write18,



      immediatewrite18formatcommand


      the defs seem to not be expanding, since I'm getting def is not an executable..., meaning that write18 sent the body of formatcommand without expanding it to the command line. How can this be fixed?



      MWE



      documentclass[border=1cm]standalone


      begindocument

      newcommandformatcommand[1]
      deftemp#1
      defsifxtempempty emptyelse not emptyfi
      echo "s"


      formatcommand
      formatcommand

      immediatewrite18formatcommand

      enddocument









      share|improve this question














      I have defined the following command:



      newcommandformatcommand[1]
      deftemp#1
      defsifxtempempty emptyelse not emptyfi
      echo "s"



      This works correctly:



      formatcommand
      formatcommand


      sample



      However, when using the above command inside write18,



      immediatewrite18formatcommand


      the defs seem to not be expanding, since I'm getting def is not an executable..., meaning that write18 sent the body of formatcommand without expanding it to the command line. How can this be fixed?



      MWE



      documentclass[border=1cm]standalone


      begindocument

      newcommandformatcommand[1]
      deftemp#1
      defsifxtempempty emptyelse not emptyfi
      echo "s"


      formatcommand
      formatcommand

      immediatewrite18formatcommand

      enddocument






      expansion shell-escape definition






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 11 hours ago









      AnakhandAnakhand

      2351 silver badge11 bronze badges




      2351 silver badge11 bronze badges























          2 Answers
          2






          active

          oldest

          votes


















          3














          When TeX writes the contents of a write command, it expands all material similarly to what happens on an edef defintion, i.e. all expandable commands are expanded but no execution happens. Macro definitions (or other assignments) are not expandable, so the defs remain in the input stream when they are written as shell commands.



          The solution is to use a fully-expandable test for an empty token list, like the following ifempty macro:



          makeatletter
          newcommandifempty[1]%
          ifrelaxdetokenize#1relax
          expandafter@firstoftwo
          else
          expandafter@secondoftwo
          fi

          makeatother

          newcommandformatcommand[1]
          echo "ifempty#1emptynot empty"






          share|improve this answer


































            1














            Generally I recommend siracusa'a solution, but if you LuaTeX there is another trick which you can use if your problem can't be written in an expandable manner:



            LuaTeX has primitives immediateassignment and immediateassigned which allow expandable defs:



            documentclass[border=1cm]standalone


            begindocument

            newcommandformatcommand[1]
            immediateassignmentdeftemp#1
            immediateassignmentdefsifxtempempty emptyelse not emptyfi
            echo "s"


            formatcommand
            formatcommand

            immediatewrite255formatcommand

            enddocument


            (I replaced write18 with write255 to show the command on the terminal because shell-escape works differently in LuaTeX, so executing the command would have needed bigger changes.)



            Using immediateassigned, you can make all assignments in a block expandable:



            documentclass[border=1cm]standalone


            begindocument

            newcommandformatcommand[1]
            immediateassigned%
            deftemp#1
            defsifxtempempty emptyelse not emptyfi
            %
            echo "s"


            formatcommand
            formatcommand

            immediatewrite255formatcommand

            enddocument





            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',
              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%2f504697%2fexpand-def-in-write18%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














              When TeX writes the contents of a write command, it expands all material similarly to what happens on an edef defintion, i.e. all expandable commands are expanded but no execution happens. Macro definitions (or other assignments) are not expandable, so the defs remain in the input stream when they are written as shell commands.



              The solution is to use a fully-expandable test for an empty token list, like the following ifempty macro:



              makeatletter
              newcommandifempty[1]%
              ifrelaxdetokenize#1relax
              expandafter@firstoftwo
              else
              expandafter@secondoftwo
              fi

              makeatother

              newcommandformatcommand[1]
              echo "ifempty#1emptynot empty"






              share|improve this answer































                3














                When TeX writes the contents of a write command, it expands all material similarly to what happens on an edef defintion, i.e. all expandable commands are expanded but no execution happens. Macro definitions (or other assignments) are not expandable, so the defs remain in the input stream when they are written as shell commands.



                The solution is to use a fully-expandable test for an empty token list, like the following ifempty macro:



                makeatletter
                newcommandifempty[1]%
                ifrelaxdetokenize#1relax
                expandafter@firstoftwo
                else
                expandafter@secondoftwo
                fi

                makeatother

                newcommandformatcommand[1]
                echo "ifempty#1emptynot empty"






                share|improve this answer





























                  3












                  3








                  3







                  When TeX writes the contents of a write command, it expands all material similarly to what happens on an edef defintion, i.e. all expandable commands are expanded but no execution happens. Macro definitions (or other assignments) are not expandable, so the defs remain in the input stream when they are written as shell commands.



                  The solution is to use a fully-expandable test for an empty token list, like the following ifempty macro:



                  makeatletter
                  newcommandifempty[1]%
                  ifrelaxdetokenize#1relax
                  expandafter@firstoftwo
                  else
                  expandafter@secondoftwo
                  fi

                  makeatother

                  newcommandformatcommand[1]
                  echo "ifempty#1emptynot empty"






                  share|improve this answer















                  When TeX writes the contents of a write command, it expands all material similarly to what happens on an edef defintion, i.e. all expandable commands are expanded but no execution happens. Macro definitions (or other assignments) are not expandable, so the defs remain in the input stream when they are written as shell commands.



                  The solution is to use a fully-expandable test for an empty token list, like the following ifempty macro:



                  makeatletter
                  newcommandifempty[1]%
                  ifrelaxdetokenize#1relax
                  expandafter@firstoftwo
                  else
                  expandafter@secondoftwo
                  fi

                  makeatother

                  newcommandformatcommand[1]
                  echo "ifempty#1emptynot empty"







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 11 hours ago

























                  answered 11 hours ago









                  siracusasiracusa

                  7,9812 gold badges18 silver badges35 bronze badges




                  7,9812 gold badges18 silver badges35 bronze badges


























                      1














                      Generally I recommend siracusa'a solution, but if you LuaTeX there is another trick which you can use if your problem can't be written in an expandable manner:



                      LuaTeX has primitives immediateassignment and immediateassigned which allow expandable defs:



                      documentclass[border=1cm]standalone


                      begindocument

                      newcommandformatcommand[1]
                      immediateassignmentdeftemp#1
                      immediateassignmentdefsifxtempempty emptyelse not emptyfi
                      echo "s"


                      formatcommand
                      formatcommand

                      immediatewrite255formatcommand

                      enddocument


                      (I replaced write18 with write255 to show the command on the terminal because shell-escape works differently in LuaTeX, so executing the command would have needed bigger changes.)



                      Using immediateassigned, you can make all assignments in a block expandable:



                      documentclass[border=1cm]standalone


                      begindocument

                      newcommandformatcommand[1]
                      immediateassigned%
                      deftemp#1
                      defsifxtempempty emptyelse not emptyfi
                      %
                      echo "s"


                      formatcommand
                      formatcommand

                      immediatewrite255formatcommand

                      enddocument





                      share|improve this answer





























                        1














                        Generally I recommend siracusa'a solution, but if you LuaTeX there is another trick which you can use if your problem can't be written in an expandable manner:



                        LuaTeX has primitives immediateassignment and immediateassigned which allow expandable defs:



                        documentclass[border=1cm]standalone


                        begindocument

                        newcommandformatcommand[1]
                        immediateassignmentdeftemp#1
                        immediateassignmentdefsifxtempempty emptyelse not emptyfi
                        echo "s"


                        formatcommand
                        formatcommand

                        immediatewrite255formatcommand

                        enddocument


                        (I replaced write18 with write255 to show the command on the terminal because shell-escape works differently in LuaTeX, so executing the command would have needed bigger changes.)



                        Using immediateassigned, you can make all assignments in a block expandable:



                        documentclass[border=1cm]standalone


                        begindocument

                        newcommandformatcommand[1]
                        immediateassigned%
                        deftemp#1
                        defsifxtempempty emptyelse not emptyfi
                        %
                        echo "s"


                        formatcommand
                        formatcommand

                        immediatewrite255formatcommand

                        enddocument





                        share|improve this answer



























                          1












                          1








                          1







                          Generally I recommend siracusa'a solution, but if you LuaTeX there is another trick which you can use if your problem can't be written in an expandable manner:



                          LuaTeX has primitives immediateassignment and immediateassigned which allow expandable defs:



                          documentclass[border=1cm]standalone


                          begindocument

                          newcommandformatcommand[1]
                          immediateassignmentdeftemp#1
                          immediateassignmentdefsifxtempempty emptyelse not emptyfi
                          echo "s"


                          formatcommand
                          formatcommand

                          immediatewrite255formatcommand

                          enddocument


                          (I replaced write18 with write255 to show the command on the terminal because shell-escape works differently in LuaTeX, so executing the command would have needed bigger changes.)



                          Using immediateassigned, you can make all assignments in a block expandable:



                          documentclass[border=1cm]standalone


                          begindocument

                          newcommandformatcommand[1]
                          immediateassigned%
                          deftemp#1
                          defsifxtempempty emptyelse not emptyfi
                          %
                          echo "s"


                          formatcommand
                          formatcommand

                          immediatewrite255formatcommand

                          enddocument





                          share|improve this answer













                          Generally I recommend siracusa'a solution, but if you LuaTeX there is another trick which you can use if your problem can't be written in an expandable manner:



                          LuaTeX has primitives immediateassignment and immediateassigned which allow expandable defs:



                          documentclass[border=1cm]standalone


                          begindocument

                          newcommandformatcommand[1]
                          immediateassignmentdeftemp#1
                          immediateassignmentdefsifxtempempty emptyelse not emptyfi
                          echo "s"


                          formatcommand
                          formatcommand

                          immediatewrite255formatcommand

                          enddocument


                          (I replaced write18 with write255 to show the command on the terminal because shell-escape works differently in LuaTeX, so executing the command would have needed bigger changes.)



                          Using immediateassigned, you can make all assignments in a block expandable:



                          documentclass[border=1cm]standalone


                          begindocument

                          newcommandformatcommand[1]
                          immediateassigned%
                          deftemp#1
                          defsifxtempempty emptyelse not emptyfi
                          %
                          echo "s"


                          formatcommand
                          formatcommand

                          immediatewrite255formatcommand

                          enddocument






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 10 hours ago









                          Marcel KrügerMarcel Krüger

                          15.2k1 gold badge18 silver badges38 bronze badges




                          15.2k1 gold badge18 silver badges38 bronze badges






























                              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%2f504697%2fexpand-def-in-write18%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

                              Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                              Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                              199年 目錄 大件事 到箇年出世嗰人 到箇年死嗰人 節慶、風俗習慣 導覽選單