Problem with stored values, macro options, and interaction with other package The 2019 Stack...
Have you ever entered Singapore using a different passport or name?
Is three citations per paragraph excessive for undergraduate research paper?
Is an up-to-date browser secure on an out-of-date OS?
Are there any other methods to apply to solving simultaneous equations?
Am I thawing this London Broil safely?
Write faster on AT24C32
Why do some words that are not inflected have an umlaut?
Output the Arecibo Message
Why is my custom API endpoint not working?
How to manage monthly salary
Why do UK politicians seemingly ignore opinion polls on Brexit?
Return to UK after being refused entry years previously
What is the accessibility of a package's `Private` context variables?
If a Druid sees an animal’s corpse, can they wild shape into that animal?
How come people say “Would of”?
What is the formula behind each level spell slot progression that I can use in a spreadsheet?
Right tool to dig six foot holes?
Apparent duplicates between Haynes service instructions and MOT
Multiply Two Integer Polynomials
Delete all lines which don't have n characters before delimiter
Are there incongruent pythagorean triangles with the same perimeter and same area?
Why can Shazam fly?
One word riddle: Vowel in the middle
Earliest use of the term "Galois extension"?
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
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
RequirePackage{filecontents}
begin{filecontents}{discourse.sty}
NeedsTeXFormat{LaTeX2e}
ProvidesPackage{discourse}
RequirePackage[user,savepos]{zref}
RequirePackage{expex}
newcounter{linenum}
newlength{largestspkr}
newlength{largestnum}
newcommand{deflargestlabel}[2][99]{
settowidth{largestnum}{#1}
settowidth{largestspkr}{~#2}}
deflargestlabel[999]{speaker~99}
RequirePackage{perpage}
newcounter{spkrcounter}
MakePerPage{spkrcounter}
newenvironment{discourseenv}{%
setcounter{linenum}{0}%
setcounter{spkrcounter}{0}%
ignorespaces
}{%
parignorespacesafterend
}
DeclareOption{skiprepetitions}{%
AtBeginDocument{letdiscourse@printdiscourse@print@skip}%
}
DeclareOption{keeprepetitions}{%
AtBeginDocument{letdiscourse@printdiscourse@print@keep}%
}
ExecuteOptions{skiprepetitions}
ProcessOptionsrelax
RequirePackage{xifthen}
defdiscourse@storedval{} % create a macro to later store a value in
newcommand{spkr}[1]{%
% create line numbers:
refstepcounter{linenum}makebox[largestnum][r]{thelinenum}hspace{1em}
ifthenelse{isempty{#1}}%
{makebox[largestspkr][l]{}}% if empty > empty box
{% If this is the first stepcounter{spkrcounter} executed since the current
% page was started, this sets 'spkrcounter' to 1.
stepcounter{spkrcounter}%
discourse@print{#1}%
defdiscourse@storedval{#1}%
}%
}
defdiscourse@print@skip#1{%
ifthenelse{cnttest{value{spkrcounter}}>{1}AND
equal{#1}{discourse@storedval}}%
{makebox[largestspkr][l]{}}% if repeated > empty box
{makebox[largestspkr][l]{#1:}}%
}
defdiscourse@print@keep#1{makebox[largestspkr][l]{#1:}}
end{filecontents}
documentclass{article}
usepackage{discourse}
begin{document}
Here it works:
spkr{A} OK
spkr{A} OK
spkr{B} OK
spkr{A} OK
vbox{}
Here too in the environment:
begin{discourseenv}
spkr{A} OK
spkr{A} OK
spkr{B} OK
end{discourseenv}
vbox{}
But in combination with expex it screws up:
begin{discourseenv}
ex[exno=spkr{A}, exnoformat=X] OK (prints A) xe
ex[exno=spkr{A}, exnoformat=X] OK (empty) xe
ex[exno=spkr{B}, exnoformat=X] OK (prints B) xe
ex[exno=spkr{A}, exnoformat=X] OK (empty) xe
ex[exno=spkr{B}, exnoformat=X] OK (prints B) xe
end{discourseenv}
begin{discourseenv}
ex[exno=spkr{B}, exnoformat=X] OK (prints B) xe
newpage
ex[exno=spkr{B}, exnoformat=X] OK (prints B) xe
ex[exno=spkr{B}, exnoformat=X] This one should be empty xe
ex[exno=spkr{B}, exnoformat=X] This one should be empty xe
ex[exno=spkr{A}, exnoformat=X] This one should print A xe
ex[exno=spkr{A}, exnoformat=X] OK (empty) xe
end{discourseenv}
end{document}
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
add a comment |
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
RequirePackage{filecontents}
begin{filecontents}{discourse.sty}
NeedsTeXFormat{LaTeX2e}
ProvidesPackage{discourse}
RequirePackage[user,savepos]{zref}
RequirePackage{expex}
newcounter{linenum}
newlength{largestspkr}
newlength{largestnum}
newcommand{deflargestlabel}[2][99]{
settowidth{largestnum}{#1}
settowidth{largestspkr}{~#2}}
deflargestlabel[999]{speaker~99}
RequirePackage{perpage}
newcounter{spkrcounter}
MakePerPage{spkrcounter}
newenvironment{discourseenv}{%
setcounter{linenum}{0}%
setcounter{spkrcounter}{0}%
ignorespaces
}{%
parignorespacesafterend
}
DeclareOption{skiprepetitions}{%
AtBeginDocument{letdiscourse@printdiscourse@print@skip}%
}
DeclareOption{keeprepetitions}{%
AtBeginDocument{letdiscourse@printdiscourse@print@keep}%
}
ExecuteOptions{skiprepetitions}
ProcessOptionsrelax
RequirePackage{xifthen}
defdiscourse@storedval{} % create a macro to later store a value in
newcommand{spkr}[1]{%
% create line numbers:
refstepcounter{linenum}makebox[largestnum][r]{thelinenum}hspace{1em}
ifthenelse{isempty{#1}}%
{makebox[largestspkr][l]{}}% if empty > empty box
{% If this is the first stepcounter{spkrcounter} executed since the current
% page was started, this sets 'spkrcounter' to 1.
stepcounter{spkrcounter}%
discourse@print{#1}%
defdiscourse@storedval{#1}%
}%
}
defdiscourse@print@skip#1{%
ifthenelse{cnttest{value{spkrcounter}}>{1}AND
equal{#1}{discourse@storedval}}%
{makebox[largestspkr][l]{}}% if repeated > empty box
{makebox[largestspkr][l]{#1:}}%
}
defdiscourse@print@keep#1{makebox[largestspkr][l]{#1:}}
end{filecontents}
documentclass{article}
usepackage{discourse}
begin{document}
Here it works:
spkr{A} OK
spkr{A} OK
spkr{B} OK
spkr{A} OK
vbox{}
Here too in the environment:
begin{discourseenv}
spkr{A} OK
spkr{A} OK
spkr{B} OK
end{discourseenv}
vbox{}
But in combination with expex it screws up:
begin{discourseenv}
ex[exno=spkr{A}, exnoformat=X] OK (prints A) xe
ex[exno=spkr{A}, exnoformat=X] OK (empty) xe
ex[exno=spkr{B}, exnoformat=X] OK (prints B) xe
ex[exno=spkr{A}, exnoformat=X] OK (empty) xe
ex[exno=spkr{B}, exnoformat=X] OK (prints B) xe
end{discourseenv}
begin{discourseenv}
ex[exno=spkr{B}, exnoformat=X] OK (prints B) xe
newpage
ex[exno=spkr{B}, exnoformat=X] OK (prints B) xe
ex[exno=spkr{B}, exnoformat=X] This one should be empty xe
ex[exno=spkr{B}, exnoformat=X] This one should be empty xe
ex[exno=spkr{A}, exnoformat=X] This one should print A xe
ex[exno=spkr{A}, exnoformat=X] OK (empty) xe
end{discourseenv}
end{document}
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
add a comment |
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
RequirePackage{filecontents}
begin{filecontents}{discourse.sty}
NeedsTeXFormat{LaTeX2e}
ProvidesPackage{discourse}
RequirePackage[user,savepos]{zref}
RequirePackage{expex}
newcounter{linenum}
newlength{largestspkr}
newlength{largestnum}
newcommand{deflargestlabel}[2][99]{
settowidth{largestnum}{#1}
settowidth{largestspkr}{~#2}}
deflargestlabel[999]{speaker~99}
RequirePackage{perpage}
newcounter{spkrcounter}
MakePerPage{spkrcounter}
newenvironment{discourseenv}{%
setcounter{linenum}{0}%
setcounter{spkrcounter}{0}%
ignorespaces
}{%
parignorespacesafterend
}
DeclareOption{skiprepetitions}{%
AtBeginDocument{letdiscourse@printdiscourse@print@skip}%
}
DeclareOption{keeprepetitions}{%
AtBeginDocument{letdiscourse@printdiscourse@print@keep}%
}
ExecuteOptions{skiprepetitions}
ProcessOptionsrelax
RequirePackage{xifthen}
defdiscourse@storedval{} % create a macro to later store a value in
newcommand{spkr}[1]{%
% create line numbers:
refstepcounter{linenum}makebox[largestnum][r]{thelinenum}hspace{1em}
ifthenelse{isempty{#1}}%
{makebox[largestspkr][l]{}}% if empty > empty box
{% If this is the first stepcounter{spkrcounter} executed since the current
% page was started, this sets 'spkrcounter' to 1.
stepcounter{spkrcounter}%
discourse@print{#1}%
defdiscourse@storedval{#1}%
}%
}
defdiscourse@print@skip#1{%
ifthenelse{cnttest{value{spkrcounter}}>{1}AND
equal{#1}{discourse@storedval}}%
{makebox[largestspkr][l]{}}% if repeated > empty box
{makebox[largestspkr][l]{#1:}}%
}
defdiscourse@print@keep#1{makebox[largestspkr][l]{#1:}}
end{filecontents}
documentclass{article}
usepackage{discourse}
begin{document}
Here it works:
spkr{A} OK
spkr{A} OK
spkr{B} OK
spkr{A} OK
vbox{}
Here too in the environment:
begin{discourseenv}
spkr{A} OK
spkr{A} OK
spkr{B} OK
end{discourseenv}
vbox{}
But in combination with expex it screws up:
begin{discourseenv}
ex[exno=spkr{A}, exnoformat=X] OK (prints A) xe
ex[exno=spkr{A}, exnoformat=X] OK (empty) xe
ex[exno=spkr{B}, exnoformat=X] OK (prints B) xe
ex[exno=spkr{A}, exnoformat=X] OK (empty) xe
ex[exno=spkr{B}, exnoformat=X] OK (prints B) xe
end{discourseenv}
begin{discourseenv}
ex[exno=spkr{B}, exnoformat=X] OK (prints B) xe
newpage
ex[exno=spkr{B}, exnoformat=X] OK (prints B) xe
ex[exno=spkr{B}, exnoformat=X] This one should be empty xe
ex[exno=spkr{B}, exnoformat=X] This one should be empty xe
ex[exno=spkr{A}, exnoformat=X] This one should print A xe
ex[exno=spkr{A}, exnoformat=X] OK (empty) xe
end{discourseenv}
end{document}
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
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
RequirePackage{filecontents}
begin{filecontents}{discourse.sty}
NeedsTeXFormat{LaTeX2e}
ProvidesPackage{discourse}
RequirePackage[user,savepos]{zref}
RequirePackage{expex}
newcounter{linenum}
newlength{largestspkr}
newlength{largestnum}
newcommand{deflargestlabel}[2][99]{
settowidth{largestnum}{#1}
settowidth{largestspkr}{~#2}}
deflargestlabel[999]{speaker~99}
RequirePackage{perpage}
newcounter{spkrcounter}
MakePerPage{spkrcounter}
newenvironment{discourseenv}{%
setcounter{linenum}{0}%
setcounter{spkrcounter}{0}%
ignorespaces
}{%
parignorespacesafterend
}
DeclareOption{skiprepetitions}{%
AtBeginDocument{letdiscourse@printdiscourse@print@skip}%
}
DeclareOption{keeprepetitions}{%
AtBeginDocument{letdiscourse@printdiscourse@print@keep}%
}
ExecuteOptions{skiprepetitions}
ProcessOptionsrelax
RequirePackage{xifthen}
defdiscourse@storedval{} % create a macro to later store a value in
newcommand{spkr}[1]{%
% create line numbers:
refstepcounter{linenum}makebox[largestnum][r]{thelinenum}hspace{1em}
ifthenelse{isempty{#1}}%
{makebox[largestspkr][l]{}}% if empty > empty box
{% If this is the first stepcounter{spkrcounter} executed since the current
% page was started, this sets 'spkrcounter' to 1.
stepcounter{spkrcounter}%
discourse@print{#1}%
defdiscourse@storedval{#1}%
}%
}
defdiscourse@print@skip#1{%
ifthenelse{cnttest{value{spkrcounter}}>{1}AND
equal{#1}{discourse@storedval}}%
{makebox[largestspkr][l]{}}% if repeated > empty box
{makebox[largestspkr][l]{#1:}}%
}
defdiscourse@print@keep#1{makebox[largestspkr][l]{#1:}}
end{filecontents}
documentclass{article}
usepackage{discourse}
begin{document}
Here it works:
spkr{A} OK
spkr{A} OK
spkr{B} OK
spkr{A} OK
vbox{}
Here too in the environment:
begin{discourseenv}
spkr{A} OK
spkr{A} OK
spkr{B} OK
end{discourseenv}
vbox{}
But in combination with expex it screws up:
begin{discourseenv}
ex[exno=spkr{A}, exnoformat=X] OK (prints A) xe
ex[exno=spkr{A}, exnoformat=X] OK (empty) xe
ex[exno=spkr{B}, exnoformat=X] OK (prints B) xe
ex[exno=spkr{A}, exnoformat=X] OK (empty) xe
ex[exno=spkr{B}, exnoformat=X] OK (prints B) xe
end{discourseenv}
begin{discourseenv}
ex[exno=spkr{B}, exnoformat=X] OK (prints B) xe
newpage
ex[exno=spkr{B}, exnoformat=X] OK (prints B) xe
ex[exno=spkr{B}, exnoformat=X] This one should be empty xe
ex[exno=spkr{B}, exnoformat=X] This one should be empty xe
ex[exno=spkr{A}, exnoformat=X] This one should print A xe
ex[exno=spkr{A}, exnoformat=X] OK (empty) xe
end{discourseenv}
end{document}
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
macros conditionals expex options
asked 3 mins ago
janjan
1,0631519
1,0631519
add a comment |
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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