Problem with stored values, macro options, and interaction with other package The 2019 Stack Overflow Developer Survey Results Are InInterlinear glosses with overlaps, line numbers, and speaker labelsReset stored values at pagebreaks and environment boundariesCreate macro with several optionsProblem if csv list is stored in macro for later use with forcsvlistProblem with addition and macro argumentProblem with csname macro expansionProblem with defined macro and blank linesNewDocumentCommand with argument specifiers stored in macroProblem with macroProblem with dynamic nested macro definitionspackage graphicx and ifthen problemReset stored values at pagebreaks and environment boundaries

If I score a critical hit on an 18 or higher, what are my chances of getting a critical hit if I roll 3d20?

Why did Acorn's A3000 have red function keys?

Why is the maximum length of OpenWrt’s root password 8 characters?

Identify This Plant (Flower)

Can someone be penalized for an "unlawful" act if no penalty is specified?

Sci-fi book where a human is taken from Earth to help man an alien ship in a fight against other aliens and rises through the ranks to command

Can you compress metal and what would be the consequences?

Why is my custom API endpoint not working?

What does ひと匙 mean in this manga and has it been used colloquially?

Do these rules for Critical Successes and Critical Failures seem Fair?

Shouldn't "much" here be used instead of "more"?

What is the formula behind each level spell slot progression that I can use in a spreadsheet?

What does "fetching by region is not available for SAM files" means?

Multiply Two Integer Polynomials

What could be the right powersource for 15 seconds lifespan disposable giant chainsaw?

Why can Shazam fly?

Loose spokes after only a few rides

Can we generate random numbers using irrational numbers like π and e?

FPGA - DIY Programming

What do hard-Brexiteers want with respect to the Irish border?

Is there a symbol for a right arrow with a square in the middle?

Did 3000BC Egyptians use meteoric iron weapons?

Is a "Democratic" Feudal System Possible?

What is the meaning of the verb "bear" in this context?



Problem with stored values, macro options, and interaction with other package



The 2019 Stack Overflow Developer Survey Results Are InInterlinear glosses with overlaps, line numbers, and speaker labelsReset stored values at pagebreaks and environment boundariesCreate macro with several optionsProblem if csv list is stored in macro for later use with forcsvlistProblem with addition and macro argumentProblem with csname macro expansionProblem with defined macro and blank linesNewDocumentCommand with argument specifiers stored in macroProblem with macroProblem with dynamic nested macro definitionspackage graphicx and ifthen problemReset stored values at pagebreaks and environment boundaries










0















Apologies for the rather general title, while trying to sort out a very specific problem:

I'm trying to enhance the framework that Alan Munn provided here
to represent naturally occurring discourse (with some extras, omitted here), with code from this answer by frougon.
The point of it all is to have a mechanism for Alan's code (which uses the expex package) to not print repeated labels of speakers. I thought I would be able to integrate the two solutions, yet, with increased complexity, somehow along the way I managed to screw it up and for the life of me I can't figure out what's wrong.



This is as minimal a WE as it gets:



% !TEX TS-program = xelatexmk
RequirePackagefilecontents

beginfilecontentsdiscourse.sty
NeedsTeXFormatLaTeX2e
ProvidesPackagediscourse

RequirePackage[user,savepos]zref
RequirePackageexpex
newcounterlinenum
newlengthlargestspkr
newlengthlargestnum
newcommanddeflargestlabel[2][99]
settowidthlargestnum#1
settowidthlargestspkr~#2
deflargestlabel[999]speaker~99

RequirePackageperpage

newcounterspkrcounter
MakePerPagespkrcounter

newenvironmentdiscourseenv%
setcounterlinenum0%
setcounterspkrcounter0%
ignorespaces
%
parignorespacesafterend


DeclareOptionskiprepetitions%
AtBeginDocumentletdiscourse@printdiscourse@print@skip%

DeclareOptionkeeprepetitions%
AtBeginDocumentletdiscourse@printdiscourse@print@keep%

ExecuteOptionsskiprepetitions
ProcessOptionsrelax

RequirePackagexifthen

defdiscourse@storedval % create a macro to later store a value in

newcommandspkr[1]%
% create line numbers:
refstepcounterlinenummakebox[largestnum][r]thelinenumhspace1em
ifthenelseisempty#1%
makebox[largestspkr][l]% if empty > empty box
% If this is the first stepcounterspkrcounter executed since the current
% page was started, this sets 'spkrcounter' to 1.
stepcounterspkrcounter%
discourse@print#1%
defdiscourse@storedval#1%
%


defdiscourse@print@skip#1%
ifthenelsecnttestvaluespkrcounter>1AND
equal#1discourse@storedval%
makebox[largestspkr][l]% if repeated > empty box
makebox[largestspkr][l]#1:%

defdiscourse@print@keep#1makebox[largestspkr][l]#1:

endfilecontents

documentclassarticle
usepackagediscourse

begindocument

Here it works:

spkrA OK

spkrA OK

spkrB OK

spkrA OK

vbox
Here too in the environment:

begindiscourseenv

spkrA OK

spkrA OK

spkrB OK

enddiscourseenv

vbox
But in combination with expex it screws up:

begindiscourseenv

ex[exno=spkrA, exnoformat=X] OK (prints A) xe

ex[exno=spkrA, exnoformat=X] OK (empty) xe

ex[exno=spkrB, exnoformat=X] OK (prints B) xe

ex[exno=spkrA, exnoformat=X] OK (empty) xe

ex[exno=spkrB, exnoformat=X] OK (prints B) xe

enddiscourseenv

begindiscourseenv

ex[exno=spkrB, exnoformat=X] OK (prints B) xe

newpage

ex[exno=spkrB, exnoformat=X] OK (prints B) xe

ex[exno=spkrB, exnoformat=X] This one should be empty xe

ex[exno=spkrB, exnoformat=X] This one should be empty xe

ex[exno=spkrA, exnoformat=X] This one should print A xe

ex[exno=spkrA, exnoformat=X] OK (empty) xe

enddiscourseenv

enddocument


It works as expected on the first couple of instances of the spkr macro, but on the next page it behaves weirdly. Anyone able to spot what's wrong?










share|improve this question


























    0















    Apologies for the rather general title, while trying to sort out a very specific problem:

    I'm trying to enhance the framework that Alan Munn provided here
    to represent naturally occurring discourse (with some extras, omitted here), with code from this answer by frougon.
    The point of it all is to have a mechanism for Alan's code (which uses the expex package) to not print repeated labels of speakers. I thought I would be able to integrate the two solutions, yet, with increased complexity, somehow along the way I managed to screw it up and for the life of me I can't figure out what's wrong.



    This is as minimal a WE as it gets:



    % !TEX TS-program = xelatexmk
    RequirePackagefilecontents

    beginfilecontentsdiscourse.sty
    NeedsTeXFormatLaTeX2e
    ProvidesPackagediscourse

    RequirePackage[user,savepos]zref
    RequirePackageexpex
    newcounterlinenum
    newlengthlargestspkr
    newlengthlargestnum
    newcommanddeflargestlabel[2][99]
    settowidthlargestnum#1
    settowidthlargestspkr~#2
    deflargestlabel[999]speaker~99

    RequirePackageperpage

    newcounterspkrcounter
    MakePerPagespkrcounter

    newenvironmentdiscourseenv%
    setcounterlinenum0%
    setcounterspkrcounter0%
    ignorespaces
    %
    parignorespacesafterend


    DeclareOptionskiprepetitions%
    AtBeginDocumentletdiscourse@printdiscourse@print@skip%

    DeclareOptionkeeprepetitions%
    AtBeginDocumentletdiscourse@printdiscourse@print@keep%

    ExecuteOptionsskiprepetitions
    ProcessOptionsrelax

    RequirePackagexifthen

    defdiscourse@storedval % create a macro to later store a value in

    newcommandspkr[1]%
    % create line numbers:
    refstepcounterlinenummakebox[largestnum][r]thelinenumhspace1em
    ifthenelseisempty#1%
    makebox[largestspkr][l]% if empty > empty box
    % If this is the first stepcounterspkrcounter executed since the current
    % page was started, this sets 'spkrcounter' to 1.
    stepcounterspkrcounter%
    discourse@print#1%
    defdiscourse@storedval#1%
    %


    defdiscourse@print@skip#1%
    ifthenelsecnttestvaluespkrcounter>1AND
    equal#1discourse@storedval%
    makebox[largestspkr][l]% if repeated > empty box
    makebox[largestspkr][l]#1:%

    defdiscourse@print@keep#1makebox[largestspkr][l]#1:

    endfilecontents

    documentclassarticle
    usepackagediscourse

    begindocument

    Here it works:

    spkrA OK

    spkrA OK

    spkrB OK

    spkrA OK

    vbox
    Here too in the environment:

    begindiscourseenv

    spkrA OK

    spkrA OK

    spkrB OK

    enddiscourseenv

    vbox
    But in combination with expex it screws up:

    begindiscourseenv

    ex[exno=spkrA, exnoformat=X] OK (prints A) xe

    ex[exno=spkrA, exnoformat=X] OK (empty) xe

    ex[exno=spkrB, exnoformat=X] OK (prints B) xe

    ex[exno=spkrA, exnoformat=X] OK (empty) xe

    ex[exno=spkrB, exnoformat=X] OK (prints B) xe

    enddiscourseenv

    begindiscourseenv

    ex[exno=spkrB, exnoformat=X] OK (prints B) xe

    newpage

    ex[exno=spkrB, exnoformat=X] OK (prints B) xe

    ex[exno=spkrB, exnoformat=X] This one should be empty xe

    ex[exno=spkrB, exnoformat=X] This one should be empty xe

    ex[exno=spkrA, exnoformat=X] This one should print A xe

    ex[exno=spkrA, exnoformat=X] OK (empty) xe

    enddiscourseenv

    enddocument


    It works as expected on the first couple of instances of the spkr macro, but on the next page it behaves weirdly. Anyone able to spot what's wrong?










    share|improve this question
























      0












      0








      0








      Apologies for the rather general title, while trying to sort out a very specific problem:

      I'm trying to enhance the framework that Alan Munn provided here
      to represent naturally occurring discourse (with some extras, omitted here), with code from this answer by frougon.
      The point of it all is to have a mechanism for Alan's code (which uses the expex package) to not print repeated labels of speakers. I thought I would be able to integrate the two solutions, yet, with increased complexity, somehow along the way I managed to screw it up and for the life of me I can't figure out what's wrong.



      This is as minimal a WE as it gets:



      % !TEX TS-program = xelatexmk
      RequirePackagefilecontents

      beginfilecontentsdiscourse.sty
      NeedsTeXFormatLaTeX2e
      ProvidesPackagediscourse

      RequirePackage[user,savepos]zref
      RequirePackageexpex
      newcounterlinenum
      newlengthlargestspkr
      newlengthlargestnum
      newcommanddeflargestlabel[2][99]
      settowidthlargestnum#1
      settowidthlargestspkr~#2
      deflargestlabel[999]speaker~99

      RequirePackageperpage

      newcounterspkrcounter
      MakePerPagespkrcounter

      newenvironmentdiscourseenv%
      setcounterlinenum0%
      setcounterspkrcounter0%
      ignorespaces
      %
      parignorespacesafterend


      DeclareOptionskiprepetitions%
      AtBeginDocumentletdiscourse@printdiscourse@print@skip%

      DeclareOptionkeeprepetitions%
      AtBeginDocumentletdiscourse@printdiscourse@print@keep%

      ExecuteOptionsskiprepetitions
      ProcessOptionsrelax

      RequirePackagexifthen

      defdiscourse@storedval % create a macro to later store a value in

      newcommandspkr[1]%
      % create line numbers:
      refstepcounterlinenummakebox[largestnum][r]thelinenumhspace1em
      ifthenelseisempty#1%
      makebox[largestspkr][l]% if empty > empty box
      % If this is the first stepcounterspkrcounter executed since the current
      % page was started, this sets 'spkrcounter' to 1.
      stepcounterspkrcounter%
      discourse@print#1%
      defdiscourse@storedval#1%
      %


      defdiscourse@print@skip#1%
      ifthenelsecnttestvaluespkrcounter>1AND
      equal#1discourse@storedval%
      makebox[largestspkr][l]% if repeated > empty box
      makebox[largestspkr][l]#1:%

      defdiscourse@print@keep#1makebox[largestspkr][l]#1:

      endfilecontents

      documentclassarticle
      usepackagediscourse

      begindocument

      Here it works:

      spkrA OK

      spkrA OK

      spkrB OK

      spkrA OK

      vbox
      Here too in the environment:

      begindiscourseenv

      spkrA OK

      spkrA OK

      spkrB OK

      enddiscourseenv

      vbox
      But in combination with expex it screws up:

      begindiscourseenv

      ex[exno=spkrA, exnoformat=X] OK (prints A) xe

      ex[exno=spkrA, exnoformat=X] OK (empty) xe

      ex[exno=spkrB, exnoformat=X] OK (prints B) xe

      ex[exno=spkrA, exnoformat=X] OK (empty) xe

      ex[exno=spkrB, exnoformat=X] OK (prints B) xe

      enddiscourseenv

      begindiscourseenv

      ex[exno=spkrB, exnoformat=X] OK (prints B) xe

      newpage

      ex[exno=spkrB, exnoformat=X] OK (prints B) xe

      ex[exno=spkrB, exnoformat=X] This one should be empty xe

      ex[exno=spkrB, exnoformat=X] This one should be empty xe

      ex[exno=spkrA, exnoformat=X] This one should print A xe

      ex[exno=spkrA, exnoformat=X] OK (empty) xe

      enddiscourseenv

      enddocument


      It works as expected on the first couple of instances of the spkr macro, but on the next page it behaves weirdly. Anyone able to spot what's wrong?










      share|improve this question














      Apologies for the rather general title, while trying to sort out a very specific problem:

      I'm trying to enhance the framework that Alan Munn provided here
      to represent naturally occurring discourse (with some extras, omitted here), with code from this answer by frougon.
      The point of it all is to have a mechanism for Alan's code (which uses the expex package) to not print repeated labels of speakers. I thought I would be able to integrate the two solutions, yet, with increased complexity, somehow along the way I managed to screw it up and for the life of me I can't figure out what's wrong.



      This is as minimal a WE as it gets:



      % !TEX TS-program = xelatexmk
      RequirePackagefilecontents

      beginfilecontentsdiscourse.sty
      NeedsTeXFormatLaTeX2e
      ProvidesPackagediscourse

      RequirePackage[user,savepos]zref
      RequirePackageexpex
      newcounterlinenum
      newlengthlargestspkr
      newlengthlargestnum
      newcommanddeflargestlabel[2][99]
      settowidthlargestnum#1
      settowidthlargestspkr~#2
      deflargestlabel[999]speaker~99

      RequirePackageperpage

      newcounterspkrcounter
      MakePerPagespkrcounter

      newenvironmentdiscourseenv%
      setcounterlinenum0%
      setcounterspkrcounter0%
      ignorespaces
      %
      parignorespacesafterend


      DeclareOptionskiprepetitions%
      AtBeginDocumentletdiscourse@printdiscourse@print@skip%

      DeclareOptionkeeprepetitions%
      AtBeginDocumentletdiscourse@printdiscourse@print@keep%

      ExecuteOptionsskiprepetitions
      ProcessOptionsrelax

      RequirePackagexifthen

      defdiscourse@storedval % create a macro to later store a value in

      newcommandspkr[1]%
      % create line numbers:
      refstepcounterlinenummakebox[largestnum][r]thelinenumhspace1em
      ifthenelseisempty#1%
      makebox[largestspkr][l]% if empty > empty box
      % If this is the first stepcounterspkrcounter executed since the current
      % page was started, this sets 'spkrcounter' to 1.
      stepcounterspkrcounter%
      discourse@print#1%
      defdiscourse@storedval#1%
      %


      defdiscourse@print@skip#1%
      ifthenelsecnttestvaluespkrcounter>1AND
      equal#1discourse@storedval%
      makebox[largestspkr][l]% if repeated > empty box
      makebox[largestspkr][l]#1:%

      defdiscourse@print@keep#1makebox[largestspkr][l]#1:

      endfilecontents

      documentclassarticle
      usepackagediscourse

      begindocument

      Here it works:

      spkrA OK

      spkrA OK

      spkrB OK

      spkrA OK

      vbox
      Here too in the environment:

      begindiscourseenv

      spkrA OK

      spkrA OK

      spkrB OK

      enddiscourseenv

      vbox
      But in combination with expex it screws up:

      begindiscourseenv

      ex[exno=spkrA, exnoformat=X] OK (prints A) xe

      ex[exno=spkrA, exnoformat=X] OK (empty) xe

      ex[exno=spkrB, exnoformat=X] OK (prints B) xe

      ex[exno=spkrA, exnoformat=X] OK (empty) xe

      ex[exno=spkrB, exnoformat=X] OK (prints B) xe

      enddiscourseenv

      begindiscourseenv

      ex[exno=spkrB, exnoformat=X] OK (prints B) xe

      newpage

      ex[exno=spkrB, exnoformat=X] OK (prints B) xe

      ex[exno=spkrB, exnoformat=X] This one should be empty xe

      ex[exno=spkrB, exnoformat=X] This one should be empty xe

      ex[exno=spkrA, exnoformat=X] This one should print A xe

      ex[exno=spkrA, exnoformat=X] OK (empty) xe

      enddiscourseenv

      enddocument


      It works as expected on the first couple of instances of the spkr macro, but on the next page it behaves weirdly. Anyone able to spot what's wrong?







      macros conditionals expex options






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 12 mins ago









      janjan

      1,0631519




      1,0631519




















          0






          active

          oldest

          votes












          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%2f484217%2fproblem-with-stored-values-macro-options-and-interaction-with-other-package%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          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%2f484217%2fproblem-with-stored-values-macro-options-and-interaction-with-other-package%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

          Isabella Eugénie Boyer Biographie | Références | Menu de navigationmodifiermodifier le codeComparator to Compute the Relative Value of a U.S. Dollar Amount – 1774 to Present.

          Join wedge with single bond in chemfigHow to make only one part of double bond bold with chemfig?Crossing bonds in chemfigjoining atoms in chemfig. Two adjacent molculesHow do I selectively change bond length in chemfig?Ugly bond joints in chemfigchemfig: reaction above arrowUsing the mhchem and chemfig packages in conjunctionBonding to specific element letter using chemfigResonance hybrids in chemfigScale chemfig molecule in beamer with tikzWhy does this chemfig bond with a hook start in the middle of the atom?

          Are small insurances worth itIs insurance worth it if you can afford to replace the item? If not, when is it?Is accident insurance worth it for my kids who play sportsIs insuring property for more than it is worth allowed?At what point does it become worth it to file an insurance claim?Are wage loss insurance programs worth the cost compared to having an emergency fund?When is an event worth insuring against?Is insurance worth it if you can afford to replace the item? If not, when is it?FHA loan just commenced : Any way to get any of the up-front mortgage insurance back?Which types of insurances do I need to buy?Should I carry less renter's insurance if I can self-insure?Mortgage Adviser Signed Me Up For Multiple Home and Life Insurances (UK)Why many travel insurances don't cover country of nationality?