Using a macro with parameters in everypar fails
Clash Royale CLAN TAG#URR8PPP
up vote
4
down vote
favorite
Out of curiosity, I wonder why this fails:
documentclassarticle
usepackagexparse
NewDocumentCommandblamm#1.#2!
begindocument
begingroup
obeylines
everypar=bla
CG skdjfs;ldjkf;sjkf
ERTERTERT djkfsjdfl;ksjdf;l
endgroup
enddocument
with the error: Argument of bla has an extra }.
I did look at par in the parameter text (as an argument delimiter) and vbox#1 in an everypar macro but these are not delimited arguments to a macro.
Later...
I discovered that xparse
offers a solution of sorts, though I think this might be looked upon as abuse:
documentclassarticle
usepackagexparse
NewDocumentCommandblaOO#1.#2!
begindocument
begingroup
obeylines
everypar=bla
[C][Gin] skdjfs;ldjkf;sjkf
[ERT][ERTERT] djkfsjdfl;ksjdf;l
endgroup
enddocument
I assume that this works because the pesky improve this question
add a comment . I did look at par in the parameter text (as an argument delimiter) and vbox#1 in an everypar macro but these are not delimited arguments to a macro.
Later...
I discovered that xparse
offers a solution of sorts, though I think this might be looked upon as abuse:
documentclassarticle
usepackagexparse
NewDocumentCommandblaOO#1.#2!
begindocument
begingroup
obeylines
everypar=bla
[C][Gin] skdjfs;ldjkf;sjkf
[ERT][ERTERT] djkfsjdfl;ksjdf;l
endgroup
enddocument
I assume that this works because the pesky
Is there a reason you wantobeylines
here? It makes the explanation longer ... though fundamentally the same
â Joseph Wrightâ¦
Oct 4 at 12:11
No. It was part of an earlier experiment...
â sgmoye
Oct 4 at 12:15
add a comment . I did look at par in the parameter text (as an argument delimiter) and vbox#1 in an everypar macro but these are not delimited arguments to a macro.
Later...
I discovered that xparse
offers a solution of sorts, though I think this might be looked upon as abuse:
documentclassarticle
usepackagexparse
NewDocumentCommandblaOO#1.#2!
begindocument
begingroup
obeylines
everypar=bla
[C][Gin] skdjfs;ldjkf;sjkf
[ERT][ERTERT] djkfsjdfl;ksjdf;l
endgroup
enddocument
I assume that this works because the pesky
Out of curiosity, I wonder why this fails:
documentclassarticle
usepackagexparse
NewDocumentCommandblamm#1.#2!
begindocument
begingroup
obeylines
everypar=bla
CG skdjfs;ldjkf;sjkf
ERTERTERT djkfsjdfl;ksjdf;l
endgroup
enddocument
with the error: Argument of bla has an extra .
I did look at par in the parameter text (as an argument delimiter) and vbox#1 in an everypar macro but these are not delimited arguments to a macro.
Later...
I discovered that xparse
offers a solution of sorts, though I think this might be looked upon as abuse:
documentclassarticle
usepackagexparse
NewDocumentCommandblaOO#1.#2!
begindocument
begingroup
obeylines
everypar=bla
[C][Gin] skdjfs;ldjkf;sjkf
[ERT][ERTERT] djkfsjdfl;ksjdf;l
endgroup
enddocument
I assume that this works because the pesky {
is no longer in play. This is convenient in that I can avoid putting bla
in front of each and every line (dozens of them).
tex-core
tex-core
edited Oct 4 at 17:04
asked Oct 4 at 12:05
sgmoye
3,64711225
3,64711225
Is there a reason you wantobeylines
here? It makes the explanation longer ... though fundamentally the same
â Joseph Wrightâ¦
Oct 4 at 12:11
No. It was part of an earlier experiment...
â sgmoye
Oct 4 at 12:15
add a comment |Â
Is there a reason you wantobeylines
here? It makes the explanation longer ... though fundamentally the same
â Joseph Wrightâ¦
Oct 4 at 12:11
No. It was part of an earlier experiment...
â sgmoye
Oct 4 at 12:15
Is there a reason you want
obeylines
here? It makes the explanation longer ... though fundamentally the sameâ Joseph Wrightâ¦
Oct 4 at 12:11
Is there a reason you want
obeylines
here? It makes the explanation longer ... though fundamentally the sameâ Joseph Wrightâ¦
Oct 4 at 12:11
No. It was part of an earlier experiment...
â sgmoye
Oct 4 at 12:15
No. It was part of an earlier experiment...
â sgmoye
Oct 4 at 12:15
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
5
down vote
accepted
TeX is in vertical mode when it reads your C
start-of-paragraph text. The starts a group but does not change mode. That happens when TeX reads
C
, which must be in horizontal mode and so starts a paragraph. The everypar
tokens are inserted, and your macro grabs C
as #1
(you can see this if you use a macro with only one argument). In the current case, you then have a in the input stream. That can't be
#2
, so you get a TeX error.
Probably the easiest way to avoid this is to force TeX to leave vertical mode. The standard leavevmode
won't work as it inserts some tokens that come after everypar
. We can fix that with an e-TeX definition for leavevmode
protecteddefleavevmodeifvmodeexpandafterindentfi
which can then be inserted
documentclassarticle
usepackagexparse
NewDocumentCommandblamm#1.#2!
protecteddefleavevmodeifvmodeexpandafterindentfi
begindocument
begingroup
everypar=bla
leavevmode
CG skdjfs;ldjkf;sjkf
ERTERTERT djkfsjdfl;ksjdf;l
endgroup
enddocument
1
What is e-tex specific here? The protected naturally, but it seems to work also without it.
â Ulrike Fischer
Oct 4 at 12:44
Somewhere in the TeXBook there is a warning about beginning a paragraph with{
-- can't find it now, but that should have made me think... This was a nice lesson.
â sgmoye
Oct 4 at 12:46
Actually, having TeXed the code, I find that does not work. The first line works correctly giving typesetC.G! skdjfs;ldjkf;sjkf
but the second line gives typesetE.R!ERTERT djkfsjdfl;ksjdf;l
. The code works ifleavevmode
is placed before each line.
â sgmoye
Oct 4 at 13:32
@sgmoye I've dropped theobeylines
as it makes life more tricky: perhaps you haven't?
â Joseph Wrightâ¦
Oct 4 at 14:52
@JosephWright I had absently put a return after the fist line. That led me to the discovery thatleavevmode
is required before each line, and the realization that there is no real labor-savings in using a macro with parameters insideeverypar
It would be nice if there were...
â sgmoye
Oct 4 at 16:11
 |Â
show 2 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
accepted
TeX is in vertical mode when it reads your C
start-of-paragraph text. The starts a group but does not change mode. That happens when TeX reads
C
, which must be in horizontal mode and so starts a paragraph. The everypar
tokens are inserted, and your macro grabs C
as #1
(you can see this if you use a macro with only one argument). In the current case, you then have a in the input stream. That can't be
#2
, so you get a TeX error.
Probably the easiest way to avoid this is to force TeX to leave vertical mode. The standard leavevmode
won't work as it inserts some tokens that come after everypar
. We can fix that with an e-TeX definition for leavevmode
protecteddefleavevmodeifvmodeexpandafterindentfi
which can then be inserted
documentclassarticle
usepackagexparse
NewDocumentCommandblamm#1.#2!
protecteddefleavevmodeifvmodeexpandafterindentfi
begindocument
begingroup
everypar=bla
leavevmode
CG skdjfs;ldjkf;sjkf
ERTERTERT djkfsjdfl;ksjdf;l
endgroup
enddocument
1
What is e-tex specific here? The protected naturally, but it seems to work also without it.
â Ulrike Fischer
Oct 4 at 12:44
Somewhere in the TeXBook there is a warning about beginning a paragraph with{
-- can't find it now, but that should have made me think... This was a nice lesson.
â sgmoye
Oct 4 at 12:46
Actually, having TeXed the code, I find that does not work. The first line works correctly giving typesetC.G! skdjfs;ldjkf;sjkf
but the second line gives typesetE.R!ERTERT djkfsjdfl;ksjdf;l
. The code works ifleavevmode
is placed before each line.
â sgmoye
Oct 4 at 13:32
@sgmoye I've dropped theobeylines
as it makes life more tricky: perhaps you haven't?
â Joseph Wrightâ¦
Oct 4 at 14:52
@JosephWright I had absently put a return after the fist line. That led me to the discovery thatleavevmode
is required before each line, and the realization that there is no real labor-savings in using a macro with parameters insideeverypar
It would be nice if there were...
â sgmoye
Oct 4 at 16:11
 |Â
show 2 more comments
up vote
5
down vote
accepted
TeX is in vertical mode when it reads your C
start-of-paragraph text. The starts a group but does not change mode. That happens when TeX reads
C
, which must be in horizontal mode and so starts a paragraph. The everypar
tokens are inserted, and your macro grabs C
as #1
(you can see this if you use a macro with only one argument). In the current case, you then have a in the input stream. That can't be
#2
, so you get a TeX error.
Probably the easiest way to avoid this is to force TeX to leave vertical mode. The standard leavevmode
won't work as it inserts some tokens that come after everypar
. We can fix that with an e-TeX definition for leavevmode
protecteddefleavevmodeifvmodeexpandafterindentfi
which can then be inserted
documentclassarticle
usepackagexparse
NewDocumentCommandblamm#1.#2!
protecteddefleavevmodeifvmodeexpandafterindentfi
begindocument
begingroup
everypar=bla
leavevmode
CG skdjfs;ldjkf;sjkf
ERTERTERT djkfsjdfl;ksjdf;l
endgroup
enddocument
1
What is e-tex specific here? The protected naturally, but it seems to work also without it.
â Ulrike Fischer
Oct 4 at 12:44
Somewhere in the TeXBook there is a warning about beginning a paragraph with{
-- can't find it now, but that should have made me think... This was a nice lesson.
â sgmoye
Oct 4 at 12:46
Actually, having TeXed the code, I find that does not work. The first line works correctly giving typesetC.G! skdjfs;ldjkf;sjkf
but the second line gives typesetE.R!ERTERT djkfsjdfl;ksjdf;l
. The code works ifleavevmode
is placed before each line.
â sgmoye
Oct 4 at 13:32
@sgmoye I've dropped theobeylines
as it makes life more tricky: perhaps you haven't?
â Joseph Wrightâ¦
Oct 4 at 14:52
@JosephWright I had absently put a return after the fist line. That led me to the discovery thatleavevmode
is required before each line, and the realization that there is no real labor-savings in using a macro with parameters insideeverypar
It would be nice if there were...
â sgmoye
Oct 4 at 16:11
 |Â
show 2 more comments
up vote
5
down vote
accepted
up vote
5
down vote
accepted
TeX is in vertical mode when it reads your C
start-of-paragraph text. The starts a group but does not change mode. That happens when TeX reads
C
, which must be in horizontal mode and so starts a paragraph. The everypar
tokens are inserted, and your macro grabs C
as #1
(you can see this if you use a macro with only one argument). In the current case, you then have a in the input stream. That can't be
#2
, so you get a TeX error.
Probably the easiest way to avoid this is to force TeX to leave vertical mode. The standard leavevmode
won't work as it inserts some tokens that come after everypar
. We can fix that with an e-TeX definition for leavevmode
protecteddefleavevmodeifvmodeexpandafterindentfi
which can then be inserted
documentclassarticle
usepackagexparse
NewDocumentCommandblamm#1.#2!
protecteddefleavevmodeifvmodeexpandafterindentfi
begindocument
begingroup
everypar=bla
leavevmode
CG skdjfs;ldjkf;sjkf
ERTERTERT djkfsjdfl;ksjdf;l
endgroup
enddocument
TeX is in vertical mode when it reads your C
start-of-paragraph text. The starts a group but does not change mode. That happens when TeX reads
C
, which must be in horizontal mode and so starts a paragraph. The everypar
tokens are inserted, and your macro grabs C
as #1
(you can see this if you use a macro with only one argument). In the current case, you then have a in the input stream. That can't be
#2
, so you get a TeX error.
Probably the easiest way to avoid this is to force TeX to leave vertical mode. The standard leavevmode
won't work as it inserts some tokens that come after everypar
. We can fix that with an e-TeX definition for leavevmode
protecteddefleavevmodeifvmodeexpandafterindentfi
which can then be inserted
documentclassarticle
usepackagexparse
NewDocumentCommandblamm#1.#2!
protecteddefleavevmodeifvmodeexpandafterindentfi
begindocument
begingroup
everypar=bla
leavevmode
CG skdjfs;ldjkf;sjkf
ERTERTERT djkfsjdfl;ksjdf;l
endgroup
enddocument
answered Oct 4 at 12:33
Joseph Wrightâ¦
198k21545864
198k21545864
1
What is e-tex specific here? The protected naturally, but it seems to work also without it.
â Ulrike Fischer
Oct 4 at 12:44
Somewhere in the TeXBook there is a warning about beginning a paragraph with{
-- can't find it now, but that should have made me think... This was a nice lesson.
â sgmoye
Oct 4 at 12:46
Actually, having TeXed the code, I find that does not work. The first line works correctly giving typesetC.G! skdjfs;ldjkf;sjkf
but the second line gives typesetE.R!ERTERT djkfsjdfl;ksjdf;l
. The code works ifleavevmode
is placed before each line.
â sgmoye
Oct 4 at 13:32
@sgmoye I've dropped theobeylines
as it makes life more tricky: perhaps you haven't?
â Joseph Wrightâ¦
Oct 4 at 14:52
@JosephWright I had absently put a return after the fist line. That led me to the discovery thatleavevmode
is required before each line, and the realization that there is no real labor-savings in using a macro with parameters insideeverypar
It would be nice if there were...
â sgmoye
Oct 4 at 16:11
 |Â
show 2 more comments
1
What is e-tex specific here? The protected naturally, but it seems to work also without it.
â Ulrike Fischer
Oct 4 at 12:44
Somewhere in the TeXBook there is a warning about beginning a paragraph with{
-- can't find it now, but that should have made me think... This was a nice lesson.
â sgmoye
Oct 4 at 12:46
Actually, having TeXed the code, I find that does not work. The first line works correctly giving typesetC.G! skdjfs;ldjkf;sjkf
but the second line gives typesetE.R!ERTERT djkfsjdfl;ksjdf;l
. The code works ifleavevmode
is placed before each line.
â sgmoye
Oct 4 at 13:32
@sgmoye I've dropped theobeylines
as it makes life more tricky: perhaps you haven't?
â Joseph Wrightâ¦
Oct 4 at 14:52
@JosephWright I had absently put a return after the fist line. That led me to the discovery thatleavevmode
is required before each line, and the realization that there is no real labor-savings in using a macro with parameters insideeverypar
It would be nice if there were...
â sgmoye
Oct 4 at 16:11
1
1
What is e-tex specific here? The protected naturally, but it seems to work also without it.
â Ulrike Fischer
Oct 4 at 12:44
What is e-tex specific here? The protected naturally, but it seems to work also without it.
â Ulrike Fischer
Oct 4 at 12:44
Somewhere in the TeXBook there is a warning about beginning a paragraph with
{
-- can't find it now, but that should have made me think... This was a nice lesson.â sgmoye
Oct 4 at 12:46
Somewhere in the TeXBook there is a warning about beginning a paragraph with
{
-- can't find it now, but that should have made me think... This was a nice lesson.â sgmoye
Oct 4 at 12:46
Actually, having TeXed the code, I find that does not work. The first line works correctly giving typeset
C.G! skdjfs;ldjkf;sjkf
but the second line gives typeset E.R!ERTERT djkfsjdfl;ksjdf;l
. The code works if leavevmode
is placed before each line.â sgmoye
Oct 4 at 13:32
Actually, having TeXed the code, I find that does not work. The first line works correctly giving typeset
C.G! skdjfs;ldjkf;sjkf
but the second line gives typeset E.R!ERTERT djkfsjdfl;ksjdf;l
. The code works if leavevmode
is placed before each line.â sgmoye
Oct 4 at 13:32
@sgmoye I've dropped the
obeylines
as it makes life more tricky: perhaps you haven't?â Joseph Wrightâ¦
Oct 4 at 14:52
@sgmoye I've dropped the
obeylines
as it makes life more tricky: perhaps you haven't?â Joseph Wrightâ¦
Oct 4 at 14:52
@JosephWright I had absently put a return after the fist line. That led me to the discovery that
leavevmode
is required before each line, and the realization that there is no real labor-savings in using a macro with parameters inside everypar
It would be nice if there were...â sgmoye
Oct 4 at 16:11
@JosephWright I had absently put a return after the fist line. That led me to the discovery that
leavevmode
is required before each line, and the realization that there is no real labor-savings in using a macro with parameters inside everypar
It would be nice if there were...â sgmoye
Oct 4 at 16:11
 |Â
show 2 more comments
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f453789%2fusing-a-macro-with-parameters-in-everypar-fails%23new-answer', 'question_page');
);
Post as a guest
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
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
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
Is there a reason you want
obeylines
here? It makes the explanation longer ... though fundamentally the sameâ Joseph Wrightâ¦
Oct 4 at 12:11
No. It was part of an earlier experiment...
â sgmoye
Oct 4 at 12:15