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

OP Amp not amplifying audio signal

How to find if SQL server backup is encrypted with TDE without restoring the backup

What do you call someone who asks many questions?

how do we prove that a sum of two periods is still a period?

How can saying a song's name be a copyright violation?

Fair gambler's ruin problem intuition

Theorists sure want true answers to this!

What is the opposite of "eschatology"?

How do I exit BASH while loop using modulus operator?

Getting extremely large arrows with tikzcd

Is it possible to map the firing of neurons in the human brain so as to stimulate artificial memories in someone else?

Why was the shrink from 8″ made only to 5.25″ and not smaller (4″ or less)

Can a virus destroy the BIOS of a modern computer?

How do conventional missiles fly?

Processor speed limited at 0.4 Ghz

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

What Exploit Are These User Agents Trying to Use?

Was the old ablative pronoun "med" or "mēd"?

What's the meaning of "Sollensaussagen"?

What exactly is ineptocracy?

How obscure is the use of 令 in 令和?

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

Why is it a bad idea to hire a hitman to eliminate most corrupt politicians?

Using "tail" to follow a file without displaying the most recent lines



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

getting Checkpoint VPN SSL Network Extender working in the command lineHow to connect to CheckPoint VPN on Ubuntu 18.04LTS?Will the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayVPN SSL Network Extender in FirefoxLinux Checkpoint SNX tool configuration issuesCheck Point - Connect under Linux - snx + OTPSNX VPN Ububuntu 18.XXUsing Checkpoint VPN SSL Network Extender CLI with certificateVPN with network manager (nm-applet) is not workingWill the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayImport VPN config files to NetworkManager from command lineTrouble connecting to VPN using network-manager, while command line worksStart a VPN connection with PPTP protocol on command linestarting a docker service daemon breaks the vpn networkCan't connect to vpn with Network-managerVPN SSL Network Extender in FirefoxUsing Checkpoint VPN SSL Network Extender CLI with certificate

Cannot Extend partition with GParted The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election ResultsCan't increase partition size with GParted?GParted doesn't recognize the unallocated space after my current partitionWhat is the best way to add unallocated space located before to Ubuntu 12.04 partition with GParted live?I can't figure out how to extend my Arch home partition into free spaceGparted Linux Mint 18.1 issueTrying to extend but swap partition is showing as Unknown in Gparted, shows proper from fdiskRearrange partitions in gparted to extend a partitionUnable to extend partition even though unallocated space is next to it using GPartedAllocate free space to root partitiongparted: how to merge unallocated space with a partition

Marilyn Monroe Ny fiainany manokana | Jereo koa | Meny fitetezanafanitarana azy.