Using a macro with parameters in everypar fails

The name of the pictureThe name of the pictureThe name of the pictureClash 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.










share|improve this question





















  • Is there a reason you want obeylines here? It makes the explanation longer ... though fundamentally the same
    – Joseph Wright♦
    1 hour ago










  • No. It was part of an earlier experiment...
    – sgmoye
    1 hour ago














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.










share|improve this question





















  • Is there a reason you want obeylines here? It makes the explanation longer ... though fundamentally the same
    – Joseph Wright♦
    1 hour ago










  • No. It was part of an earlier experiment...
    – sgmoye
    1 hour ago












up vote
4
down vote

favorite









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.










share|improve this question













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.







tex-core






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 1 hour ago









sgmoye

3,64711125




3,64711125











  • Is there a reason you want obeylines here? It makes the explanation longer ... though fundamentally the same
    – Joseph Wright♦
    1 hour ago










  • No. It was part of an earlier experiment...
    – sgmoye
    1 hour ago
















  • Is there a reason you want obeylines here? It makes the explanation longer ... though fundamentally the same
    – Joseph Wright♦
    1 hour ago










  • No. It was part of an earlier experiment...
    – sgmoye
    1 hour ago















Is there a reason you want obeylines here? It makes the explanation longer ... though fundamentally the same
– Joseph Wright♦
1 hour ago




Is there a reason you want obeylines here? It makes the explanation longer ... though fundamentally the same
– Joseph Wright♦
1 hour ago












No. It was part of an earlier experiment...
– sgmoye
1 hour ago




No. It was part of an earlier experiment...
– sgmoye
1 hour ago










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





share|improve this answer
















  • 1




    What is e-tex specific here? The protected naturally, but it seems to work also without it.
    – Ulrike Fischer
    1 hour ago










  • 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
    1 hour ago










  • 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
    26 mins 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',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
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%2f453789%2fusing-a-macro-with-parameters-in-everypar-fails%23new-answer', 'question_page');

);

Post as a guest






























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





share|improve this answer
















  • 1




    What is e-tex specific here? The protected naturally, but it seems to work also without it.
    – Ulrike Fischer
    1 hour ago










  • 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
    1 hour ago










  • 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
    26 mins ago














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





share|improve this answer
















  • 1




    What is e-tex specific here? The protected naturally, but it seems to work also without it.
    – Ulrike Fischer
    1 hour ago










  • 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
    1 hour ago










  • 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
    26 mins ago












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





share|improve this answer












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






share|improve this answer












share|improve this answer



share|improve this answer










answered 1 hour ago









Joseph Wright♦

197k21544863




197k21544863







  • 1




    What is e-tex specific here? The protected naturally, but it seems to work also without it.
    – Ulrike Fischer
    1 hour ago










  • 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
    1 hour ago










  • 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
    26 mins ago












  • 1




    What is e-tex specific here? The protected naturally, but it seems to work also without it.
    – Ulrike Fischer
    1 hour ago










  • 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
    1 hour ago










  • 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
    26 mins ago







1




1




What is e-tex specific here? The protected naturally, but it seems to work also without it.
– Ulrike Fischer
1 hour ago




What is e-tex specific here? The protected naturally, but it seems to work also without it.
– Ulrike Fischer
1 hour ago












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
1 hour ago




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
1 hour ago












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
26 mins ago




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
26 mins ago

















 

draft saved


draft discarded















































 


draft saved


draft discarded














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













































































Comments

Popular posts from this blog

Long meetings (6-7 hours a day): Being “babysat” by supervisor

Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

Confectionery