Define command that accepts \ in argumentsHow to define a command that takes more than 9 argumentsEnumerate and itemize undefined + captions not workingDefining a newcommand for environment in CircuiTikzDefine command so that label works properlyA command to define other commands with argumentsHow to define a command that defines another command?How to define a command that takes more than 18 argumentshow to define newcommand that takes [] as arguments and not ?Can I define a macro that accepts everything until the next space?define variable with multiple arguments

Can a virus destroy the BIOS of a modern computer?

How to install cross-compiler on Ubuntu 18.04?

Is this answer explanation correct?

GFCI outlets - can they be repaired? Are they really needed at the end of a circuit?

Why didn't Boeing produce its own regional jet?

How does a dynamic QR code work?

How could indestructible materials be used in power generation?

What historical events would have to change in order to make 19th century "steampunk" technology possible?

Why do I get negative height?

How exploitable/balanced is this homebrew spell: Spell Permanency?

Why were 5.25" floppy drives cheaper than 8"?

Is it a bad idea to plug the other end of ESD strap to wall ground?

Could the museum Saturn V's be refitted for one more flight?

What's the meaning of "Sollensaussagen"?

Unlock My Phone! February 2018

How can a day be of 24 hours?

What is the most common color to indicate the input-field is disabled?

Night of Shab e Meraj

Is there an expression that means doing something right before you will need it rather than doing it in case you might need it?

Is it inappropriate for a student to attend their mentor's dissertation defense?

Bullying boss launched a smear campaign and made me unemployable

How do I exit BASH while loop using modulus operator?

Ambiguity in the definition of entropy

In Bayesian inference, why are some terms dropped from the posterior predictive?



Define command that accepts \ in arguments


How to define a command that takes more than 9 argumentsEnumerate and itemize undefined + captions not workingDefining a newcommand for environment in CircuiTikzDefine command so that label works properlyA command to define other commands with argumentsHow to define a command that defines another command?How to define a command that takes more than 18 argumentshow to define newcommand that takes [] as arguments and not ?Can I define a macro that accepts everything until the next space?define variable with multiple arguments













2















I am trying to define a new command dfix that can handle newlines in its arguments. The command works as expected when the arguments have no \ in them, but LaTeX produces errors if I do include newline characters.



How can I create a command/macro that is safe with regard to line breaks?



I would like dfix in the following context



beginalign*
&dfix(A\
&B)C
endalign*


to produce the same output as



beginalign*
&(A\
&B)^ddag_C
endalign*


Similarly, $dfixAB$ should produce the same output as $A^ddag_B$.



Here is a MWE defining the command and trying to us it in various places.



documentclassminimal
usepackageamsmath
newcommanddfix[2]ensuremath#1^ddag_#2
begindocument
% This causes: ./mwe.tex:9: Missing inserted.
beginalign*
&dfixA\
&BC
endalign*
% This is OK
beginalign*
&dfixA BC
endalign*
% This also produces errors.
beginmultline*
dfixA\
BC
endmultline*
enddocument









share|improve this question
























  • So what do you expect when using your command with many lines?

    – JouleV
    2 days ago











  • you don't say what you expect the output to be. in that context the \ is ending the row of the align, but it is inside a group (it is the group that causes the error not the newcommand)

    – David Carlisle
    2 days ago











  • Easy way to enable multiline arguments: newcommanddfix[2]ensuremathbeginarray@c@#1endarray^ddag_#2 but that still wouldn't make dfixA\&BC valid syntax. What do you want dfix to do?

    – Skillmon
    2 days ago











  • the macro has to expand to something that is valid in the align, so you can show the intended result by showing a working align that does not use dfix but makes the result you want. I can not guess from the code above,

    – David Carlisle
    2 days ago











  • I just edited the question to add an example showing the desired behaviour.

    – Ryan Kavanagh
    2 days ago















2















I am trying to define a new command dfix that can handle newlines in its arguments. The command works as expected when the arguments have no \ in them, but LaTeX produces errors if I do include newline characters.



How can I create a command/macro that is safe with regard to line breaks?



I would like dfix in the following context



beginalign*
&dfix(A\
&B)C
endalign*


to produce the same output as



beginalign*
&(A\
&B)^ddag_C
endalign*


Similarly, $dfixAB$ should produce the same output as $A^ddag_B$.



Here is a MWE defining the command and trying to us it in various places.



documentclassminimal
usepackageamsmath
newcommanddfix[2]ensuremath#1^ddag_#2
begindocument
% This causes: ./mwe.tex:9: Missing inserted.
beginalign*
&dfixA\
&BC
endalign*
% This is OK
beginalign*
&dfixA BC
endalign*
% This also produces errors.
beginmultline*
dfixA\
BC
endmultline*
enddocument









share|improve this question
























  • So what do you expect when using your command with many lines?

    – JouleV
    2 days ago











  • you don't say what you expect the output to be. in that context the \ is ending the row of the align, but it is inside a group (it is the group that causes the error not the newcommand)

    – David Carlisle
    2 days ago











  • Easy way to enable multiline arguments: newcommanddfix[2]ensuremathbeginarray@c@#1endarray^ddag_#2 but that still wouldn't make dfixA\&BC valid syntax. What do you want dfix to do?

    – Skillmon
    2 days ago











  • the macro has to expand to something that is valid in the align, so you can show the intended result by showing a working align that does not use dfix but makes the result you want. I can not guess from the code above,

    – David Carlisle
    2 days ago











  • I just edited the question to add an example showing the desired behaviour.

    – Ryan Kavanagh
    2 days ago













2












2








2








I am trying to define a new command dfix that can handle newlines in its arguments. The command works as expected when the arguments have no \ in them, but LaTeX produces errors if I do include newline characters.



How can I create a command/macro that is safe with regard to line breaks?



I would like dfix in the following context



beginalign*
&dfix(A\
&B)C
endalign*


to produce the same output as



beginalign*
&(A\
&B)^ddag_C
endalign*


Similarly, $dfixAB$ should produce the same output as $A^ddag_B$.



Here is a MWE defining the command and trying to us it in various places.



documentclassminimal
usepackageamsmath
newcommanddfix[2]ensuremath#1^ddag_#2
begindocument
% This causes: ./mwe.tex:9: Missing inserted.
beginalign*
&dfixA\
&BC
endalign*
% This is OK
beginalign*
&dfixA BC
endalign*
% This also produces errors.
beginmultline*
dfixA\
BC
endmultline*
enddocument









share|improve this question
















I am trying to define a new command dfix that can handle newlines in its arguments. The command works as expected when the arguments have no \ in them, but LaTeX produces errors if I do include newline characters.



How can I create a command/macro that is safe with regard to line breaks?



I would like dfix in the following context



beginalign*
&dfix(A\
&B)C
endalign*


to produce the same output as



beginalign*
&(A\
&B)^ddag_C
endalign*


Similarly, $dfixAB$ should produce the same output as $A^ddag_B$.



Here is a MWE defining the command and trying to us it in various places.



documentclassminimal
usepackageamsmath
newcommanddfix[2]ensuremath#1^ddag_#2
begindocument
% This causes: ./mwe.tex:9: Missing inserted.
beginalign*
&dfixA\
&BC
endalign*
% This is OK
beginalign*
&dfixA BC
endalign*
% This also produces errors.
beginmultline*
dfixA\
BC
endmultline*
enddocument






macros errors align






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago









David Carlisle

497k4111441891




497k4111441891










asked 2 days ago









Ryan KavanaghRyan Kavanagh

454




454












  • So what do you expect when using your command with many lines?

    – JouleV
    2 days ago











  • you don't say what you expect the output to be. in that context the \ is ending the row of the align, but it is inside a group (it is the group that causes the error not the newcommand)

    – David Carlisle
    2 days ago











  • Easy way to enable multiline arguments: newcommanddfix[2]ensuremathbeginarray@c@#1endarray^ddag_#2 but that still wouldn't make dfixA\&BC valid syntax. What do you want dfix to do?

    – Skillmon
    2 days ago











  • the macro has to expand to something that is valid in the align, so you can show the intended result by showing a working align that does not use dfix but makes the result you want. I can not guess from the code above,

    – David Carlisle
    2 days ago











  • I just edited the question to add an example showing the desired behaviour.

    – Ryan Kavanagh
    2 days ago

















  • So what do you expect when using your command with many lines?

    – JouleV
    2 days ago











  • you don't say what you expect the output to be. in that context the \ is ending the row of the align, but it is inside a group (it is the group that causes the error not the newcommand)

    – David Carlisle
    2 days ago











  • Easy way to enable multiline arguments: newcommanddfix[2]ensuremathbeginarray@c@#1endarray^ddag_#2 but that still wouldn't make dfixA\&BC valid syntax. What do you want dfix to do?

    – Skillmon
    2 days ago











  • the macro has to expand to something that is valid in the align, so you can show the intended result by showing a working align that does not use dfix but makes the result you want. I can not guess from the code above,

    – David Carlisle
    2 days ago











  • I just edited the question to add an example showing the desired behaviour.

    – Ryan Kavanagh
    2 days ago
















So what do you expect when using your command with many lines?

– JouleV
2 days ago





So what do you expect when using your command with many lines?

– JouleV
2 days ago













you don't say what you expect the output to be. in that context the \ is ending the row of the align, but it is inside a group (it is the group that causes the error not the newcommand)

– David Carlisle
2 days ago





you don't say what you expect the output to be. in that context the \ is ending the row of the align, but it is inside a group (it is the group that causes the error not the newcommand)

– David Carlisle
2 days ago













Easy way to enable multiline arguments: newcommanddfix[2]ensuremathbeginarray@c@#1endarray^ddag_#2 but that still wouldn't make dfixA\&BC valid syntax. What do you want dfix to do?

– Skillmon
2 days ago





Easy way to enable multiline arguments: newcommanddfix[2]ensuremathbeginarray@c@#1endarray^ddag_#2 but that still wouldn't make dfixA\&BC valid syntax. What do you want dfix to do?

– Skillmon
2 days ago













the macro has to expand to something that is valid in the align, so you can show the intended result by showing a working align that does not use dfix but makes the result you want. I can not guess from the code above,

– David Carlisle
2 days ago





the macro has to expand to something that is valid in the align, so you can show the intended result by showing a working align that does not use dfix but makes the result you want. I can not guess from the code above,

– David Carlisle
2 days ago













I just edited the question to add an example showing the desired behaviour.

– Ryan Kavanagh
2 days ago





I just edited the question to add an example showing the desired behaviour.

– Ryan Kavanagh
2 days ago










1 Answer
1






active

oldest

votes


















4














This does what you ask but seems a very weird construct, are you sure this is what you need?



documentclassminimal
usepackageamsmath
newcommanddfix[2](#1)^ddag_#2
begindocument
% This causes: ./mwe.tex:9: Missing } inserted.
beginalign*
&dfixA\
&BC
endalign*
% This is OK
beginalign*
&dfixA BC
endalign*
% This also produces errors.
beginmultline*
dfixA\
BC
endmultline*
enddocument





share|improve this answer























  • Thanks David! The parentheses are not needed inside the body of dfix. The intention is that $dfixfX$ describes an operation on a functions f. When the first argument is a single letter, then no parentheses are needed (i.e., the output should be $f^ddag_X$), but I was encountering issues when I had to split long function expression across several lines, e.g., $dfix(A\B)X$. Getting rid of the braces around #1 as you did and changing the definition to newcommanddfix[2]#1^ddag_#2 seems to have fixed my problem.

    – Ryan Kavanagh
    2 days ago











  • @RyanKavanagh OK I would never use that markup personally, having a macro argument start in one alignment cell and end in another is extremely weird, but as I show it's not technically invalid so if it does what you want, that's OK:-)

    – David Carlisle
    2 days 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',
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%2f482453%2fdefine-command-that-accepts-in-arguments%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









4














This does what you ask but seems a very weird construct, are you sure this is what you need?



documentclassminimal
usepackageamsmath
newcommanddfix[2](#1)^ddag_#2
begindocument
% This causes: ./mwe.tex:9: Missing } inserted.
beginalign*
&dfixA\
&BC
endalign*
% This is OK
beginalign*
&dfixA BC
endalign*
% This also produces errors.
beginmultline*
dfixA\
BC
endmultline*
enddocument





share|improve this answer























  • Thanks David! The parentheses are not needed inside the body of dfix. The intention is that $dfixfX$ describes an operation on a functions f. When the first argument is a single letter, then no parentheses are needed (i.e., the output should be $f^ddag_X$), but I was encountering issues when I had to split long function expression across several lines, e.g., $dfix(A\B)X$. Getting rid of the braces around #1 as you did and changing the definition to newcommanddfix[2]#1^ddag_#2 seems to have fixed my problem.

    – Ryan Kavanagh
    2 days ago











  • @RyanKavanagh OK I would never use that markup personally, having a macro argument start in one alignment cell and end in another is extremely weird, but as I show it's not technically invalid so if it does what you want, that's OK:-)

    – David Carlisle
    2 days ago















4














This does what you ask but seems a very weird construct, are you sure this is what you need?



documentclassminimal
usepackageamsmath
newcommanddfix[2](#1)^ddag_#2
begindocument
% This causes: ./mwe.tex:9: Missing } inserted.
beginalign*
&dfixA\
&BC
endalign*
% This is OK
beginalign*
&dfixA BC
endalign*
% This also produces errors.
beginmultline*
dfixA\
BC
endmultline*
enddocument





share|improve this answer























  • Thanks David! The parentheses are not needed inside the body of dfix. The intention is that $dfixfX$ describes an operation on a functions f. When the first argument is a single letter, then no parentheses are needed (i.e., the output should be $f^ddag_X$), but I was encountering issues when I had to split long function expression across several lines, e.g., $dfix(A\B)X$. Getting rid of the braces around #1 as you did and changing the definition to newcommanddfix[2]#1^ddag_#2 seems to have fixed my problem.

    – Ryan Kavanagh
    2 days ago











  • @RyanKavanagh OK I would never use that markup personally, having a macro argument start in one alignment cell and end in another is extremely weird, but as I show it's not technically invalid so if it does what you want, that's OK:-)

    – David Carlisle
    2 days ago













4












4








4







This does what you ask but seems a very weird construct, are you sure this is what you need?



documentclassminimal
usepackageamsmath
newcommanddfix[2](#1)^ddag_#2
begindocument
% This causes: ./mwe.tex:9: Missing } inserted.
beginalign*
&dfixA\
&BC
endalign*
% This is OK
beginalign*
&dfixA BC
endalign*
% This also produces errors.
beginmultline*
dfixA\
BC
endmultline*
enddocument





share|improve this answer













This does what you ask but seems a very weird construct, are you sure this is what you need?



documentclassminimal
usepackageamsmath
newcommanddfix[2](#1)^ddag_#2
begindocument
% This causes: ./mwe.tex:9: Missing } inserted.
beginalign*
&dfixA\
&BC
endalign*
% This is OK
beginalign*
&dfixA BC
endalign*
% This also produces errors.
beginmultline*
dfixA\
BC
endmultline*
enddocument






share|improve this answer












share|improve this answer



share|improve this answer










answered 2 days ago









David CarlisleDavid Carlisle

497k4111441891




497k4111441891












  • Thanks David! The parentheses are not needed inside the body of dfix. The intention is that $dfixfX$ describes an operation on a functions f. When the first argument is a single letter, then no parentheses are needed (i.e., the output should be $f^ddag_X$), but I was encountering issues when I had to split long function expression across several lines, e.g., $dfix(A\B)X$. Getting rid of the braces around #1 as you did and changing the definition to newcommanddfix[2]#1^ddag_#2 seems to have fixed my problem.

    – Ryan Kavanagh
    2 days ago











  • @RyanKavanagh OK I would never use that markup personally, having a macro argument start in one alignment cell and end in another is extremely weird, but as I show it's not technically invalid so if it does what you want, that's OK:-)

    – David Carlisle
    2 days ago

















  • Thanks David! The parentheses are not needed inside the body of dfix. The intention is that $dfixfX$ describes an operation on a functions f. When the first argument is a single letter, then no parentheses are needed (i.e., the output should be $f^ddag_X$), but I was encountering issues when I had to split long function expression across several lines, e.g., $dfix(A\B)X$. Getting rid of the braces around #1 as you did and changing the definition to newcommanddfix[2]#1^ddag_#2 seems to have fixed my problem.

    – Ryan Kavanagh
    2 days ago











  • @RyanKavanagh OK I would never use that markup personally, having a macro argument start in one alignment cell and end in another is extremely weird, but as I show it's not technically invalid so if it does what you want, that's OK:-)

    – David Carlisle
    2 days ago
















Thanks David! The parentheses are not needed inside the body of dfix. The intention is that $dfixfX$ describes an operation on a functions f. When the first argument is a single letter, then no parentheses are needed (i.e., the output should be $f^ddag_X$), but I was encountering issues when I had to split long function expression across several lines, e.g., $dfix(A\B)X$. Getting rid of the braces around #1 as you did and changing the definition to newcommanddfix[2]#1^ddag_#2 seems to have fixed my problem.

– Ryan Kavanagh
2 days ago





Thanks David! The parentheses are not needed inside the body of dfix. The intention is that $dfixfX$ describes an operation on a functions f. When the first argument is a single letter, then no parentheses are needed (i.e., the output should be $f^ddag_X$), but I was encountering issues when I had to split long function expression across several lines, e.g., $dfix(A\B)X$. Getting rid of the braces around #1 as you did and changing the definition to newcommanddfix[2]#1^ddag_#2 seems to have fixed my problem.

– Ryan Kavanagh
2 days ago













@RyanKavanagh OK I would never use that markup personally, having a macro argument start in one alignment cell and end in another is extremely weird, but as I show it's not technically invalid so if it does what you want, that's OK:-)

– David Carlisle
2 days ago





@RyanKavanagh OK I would never use that markup personally, having a macro argument start in one alignment cell and end in another is extremely weird, but as I show it's not technically invalid so if it does what you want, that's OK:-)

– David Carlisle
2 days ago

















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%2f482453%2fdefine-command-that-accepts-in-arguments%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

Sum ergo cogito? 1 nng

419 nièngy_Soadمي 19bal1.5o_g

Queiggey Chernihivv 9NnOo i Zw X QqKk LpB