How to properly capture return value of a command?medskipamount, default value in article classStore a ratio value in command and then use it to recalculate a length?Save length with let commandHow to log the value of a variable?Trim size as fundamental TeX valuenew command not working properlyGet pseudo-length value in scrlttr2Can't properly calculate column widthStandalone build command does not capture all lengthHow to add an unit to a calculated value properly?

You look catfish vs You look like a catfish

Find the coordinate of two line segments that are perpendicular

When and why did journal article titles become descriptive, rather than creatively allusive?

Why was Germany not as successful as other Europeans in establishing overseas colonies?

What is a Recurrent Neural Network?

Feels like I am getting dragged in office politics

Electric guitar: why such heavy pots?

Pulling the rope with one hand is as heavy as with two hands?

gnu parallel how to use with ffmpeg

Pawn Sacrifice Justification

Upright [...] in italics quotation

Why do Ichisongas hate elephants and hippos?

Why is current rating for multicore cable lower than single core with the same cross section?

Does a creature that is immune to a condition still make a saving throw?

Why does nature favour the Laplacian?

Confused by notation of atomic number Z and mass number A on periodic table of elements

Is it possible to Ready a spell to be cast just before the start of your next turn by having the trigger be an ally's attack?

How can Republicans who favour free markets, consistently express anger when they don't like the outcome of that choice?

What does "rf" mean in "rfkill"?

Unexpected email from Yorkshire Bank

Illegal assignment from SObject to Contact

Can someone publish a story that happened to you?

How to creep the reader out with what seems like a normal person?

How to set the font color of quantity objects (Version 11.3 vs version 12)?



How to properly capture return value of a command?


medskipamount, default value in article classStore a ratio value in command and then use it to recalculate a length?Save length with let commandHow to log the value of a variable?Trim size as fundamental TeX valuenew command not working properlyGet pseudo-length value in scrlttr2Can't properly calculate column widthStandalone build command does not capture all lengthHow to add an unit to a calculated value properly?













3















I have a problem with capturing returned value of my command.



Here is my preamble with command definition:



documentclass[convert=density=300,size=800x600,outext=.png]standalone
usepackage[utf8]inputenc
usepackagetikz

% Font used for writing commands.
defcmdFontfontsize1012selectfont

% Commands.
defcmdOne cmdFont aaa
defcmdTwo cmdFont bbbbb
defcmdThreecmdFont cccc

% Function which returns maximum width needed to write any of provided arguments.
makeatletter

newlengthtextLength@getMaximumWidthHelper
newlengthtextLength@getMaximumWidth

newcommandgetMaximumWidthHelper[2]
%
settowidthtextLength@getMaximumWidthHelperpgfinterruptpicture #2endpgfinterruptpicture%

pgfmathparsemax(#1,textLength@getMaximumWidthHelper)%
@ifnextcharbgroupgetMaximumWidthHelperpgfmathresult ptpgfmathresult pt%
%

newcommandgetMaximumWidth[1]
%
settowidthtextLength@getMaximumWidthpgfinterruptpicture #1endpgfinterruptpicture%
@ifnextcharbgroupgetMaximumWidthHelperthetextLength@getMaximumWidththetextLength@getMaximumWidth%
%

makeatother


Working example used to test the above command:



begindocument

getMaximumWidthcmdOne
getMaximumWidthcmdOnecmdTwo
getMaximumWidthcmdOnecmdTwocmdThree

enddocument


However, when I try to capture the output of getMaximumWidth, it doesn't work as expected.



begindocument

newlengthmaximumWidth
setlengthmaximumWidthgetMaximumWidthcmdOnecmdTwocmdThree
themaximumWidth

enddocument


On the second line, the return value of getMaximumWidth is not captured but instantly printed.

Afterwards I get an error:




! Missing number, treated as
zero.




After that, the third line just prints default value 0.0pt.



What is the proper way to capture the output of getMaximumWidth?



P.S. This is my first time writing Latex document, feel free to point out anything i could've done better.










share|improve this question









New contributor




Iskustvo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 1





    while @ifnextcharbgroup works you should almost never do it as it results in commands that fail to obey latex syntax conventions. All latex commands have a fixed number of arguments using delimiters and a variable number of optional arguments which use [] delimiters. You have defined a command with optional arguments which is wrong.

    – David Carlisle
    Apr 24 at 14:37












  • macros do not have return values, your getMaximumWidth expands to a series of assignments so is not a length that can be used in setlength, you need to define it to leave a length in some command, say tempresult then use getMaximumWidthcmdOnecmdTwocmdThreesetlengthmaximumWidthtempresult or using a latex-conforming syntax, getMaximumWidthcmdOne,cmdTwo,cmdThreesetlengthmaximumWidthtempresult

    – David Carlisle
    Apr 24 at 15:43












  • That is exactly why pgfmathparse leaves its answer in pgfmathresult

    – David Carlisle
    Apr 24 at 15:45











  • Thanks a lot! I am not able to test everything at the moment, but your solution seems a lot easier and can be used as I intended.

    – Iskustvo
    Apr 24 at 16:00















3















I have a problem with capturing returned value of my command.



Here is my preamble with command definition:



documentclass[convert=density=300,size=800x600,outext=.png]standalone
usepackage[utf8]inputenc
usepackagetikz

% Font used for writing commands.
defcmdFontfontsize1012selectfont

% Commands.
defcmdOne cmdFont aaa
defcmdTwo cmdFont bbbbb
defcmdThreecmdFont cccc

% Function which returns maximum width needed to write any of provided arguments.
makeatletter

newlengthtextLength@getMaximumWidthHelper
newlengthtextLength@getMaximumWidth

newcommandgetMaximumWidthHelper[2]
%
settowidthtextLength@getMaximumWidthHelperpgfinterruptpicture #2endpgfinterruptpicture%

pgfmathparsemax(#1,textLength@getMaximumWidthHelper)%
@ifnextcharbgroupgetMaximumWidthHelperpgfmathresult ptpgfmathresult pt%
%

newcommandgetMaximumWidth[1]
%
settowidthtextLength@getMaximumWidthpgfinterruptpicture #1endpgfinterruptpicture%
@ifnextcharbgroupgetMaximumWidthHelperthetextLength@getMaximumWidththetextLength@getMaximumWidth%
%

makeatother


Working example used to test the above command:



begindocument

getMaximumWidthcmdOne
getMaximumWidthcmdOnecmdTwo
getMaximumWidthcmdOnecmdTwocmdThree

enddocument


However, when I try to capture the output of getMaximumWidth, it doesn't work as expected.



begindocument

newlengthmaximumWidth
setlengthmaximumWidthgetMaximumWidthcmdOnecmdTwocmdThree
themaximumWidth

enddocument


On the second line, the return value of getMaximumWidth is not captured but instantly printed.

Afterwards I get an error:




! Missing number, treated as
zero.




After that, the third line just prints default value 0.0pt.



What is the proper way to capture the output of getMaximumWidth?



P.S. This is my first time writing Latex document, feel free to point out anything i could've done better.










share|improve this question









New contributor




Iskustvo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 1





    while @ifnextcharbgroup works you should almost never do it as it results in commands that fail to obey latex syntax conventions. All latex commands have a fixed number of arguments using delimiters and a variable number of optional arguments which use [] delimiters. You have defined a command with optional arguments which is wrong.

    – David Carlisle
    Apr 24 at 14:37












  • macros do not have return values, your getMaximumWidth expands to a series of assignments so is not a length that can be used in setlength, you need to define it to leave a length in some command, say tempresult then use getMaximumWidthcmdOnecmdTwocmdThreesetlengthmaximumWidthtempresult or using a latex-conforming syntax, getMaximumWidthcmdOne,cmdTwo,cmdThreesetlengthmaximumWidthtempresult

    – David Carlisle
    Apr 24 at 15:43












  • That is exactly why pgfmathparse leaves its answer in pgfmathresult

    – David Carlisle
    Apr 24 at 15:45











  • Thanks a lot! I am not able to test everything at the moment, but your solution seems a lot easier and can be used as I intended.

    – Iskustvo
    Apr 24 at 16:00













3












3








3








I have a problem with capturing returned value of my command.



Here is my preamble with command definition:



documentclass[convert=density=300,size=800x600,outext=.png]standalone
usepackage[utf8]inputenc
usepackagetikz

% Font used for writing commands.
defcmdFontfontsize1012selectfont

% Commands.
defcmdOne cmdFont aaa
defcmdTwo cmdFont bbbbb
defcmdThreecmdFont cccc

% Function which returns maximum width needed to write any of provided arguments.
makeatletter

newlengthtextLength@getMaximumWidthHelper
newlengthtextLength@getMaximumWidth

newcommandgetMaximumWidthHelper[2]
%
settowidthtextLength@getMaximumWidthHelperpgfinterruptpicture #2endpgfinterruptpicture%

pgfmathparsemax(#1,textLength@getMaximumWidthHelper)%
@ifnextcharbgroupgetMaximumWidthHelperpgfmathresult ptpgfmathresult pt%
%

newcommandgetMaximumWidth[1]
%
settowidthtextLength@getMaximumWidthpgfinterruptpicture #1endpgfinterruptpicture%
@ifnextcharbgroupgetMaximumWidthHelperthetextLength@getMaximumWidththetextLength@getMaximumWidth%
%

makeatother


Working example used to test the above command:



begindocument

getMaximumWidthcmdOne
getMaximumWidthcmdOnecmdTwo
getMaximumWidthcmdOnecmdTwocmdThree

enddocument


However, when I try to capture the output of getMaximumWidth, it doesn't work as expected.



begindocument

newlengthmaximumWidth
setlengthmaximumWidthgetMaximumWidthcmdOnecmdTwocmdThree
themaximumWidth

enddocument


On the second line, the return value of getMaximumWidth is not captured but instantly printed.

Afterwards I get an error:




! Missing number, treated as
zero.




After that, the third line just prints default value 0.0pt.



What is the proper way to capture the output of getMaximumWidth?



P.S. This is my first time writing Latex document, feel free to point out anything i could've done better.










share|improve this question









New contributor




Iskustvo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I have a problem with capturing returned value of my command.



Here is my preamble with command definition:



documentclass[convert=density=300,size=800x600,outext=.png]standalone
usepackage[utf8]inputenc
usepackagetikz

% Font used for writing commands.
defcmdFontfontsize1012selectfont

% Commands.
defcmdOne cmdFont aaa
defcmdTwo cmdFont bbbbb
defcmdThreecmdFont cccc

% Function which returns maximum width needed to write any of provided arguments.
makeatletter

newlengthtextLength@getMaximumWidthHelper
newlengthtextLength@getMaximumWidth

newcommandgetMaximumWidthHelper[2]
%
settowidthtextLength@getMaximumWidthHelperpgfinterruptpicture #2endpgfinterruptpicture%

pgfmathparsemax(#1,textLength@getMaximumWidthHelper)%
@ifnextcharbgroupgetMaximumWidthHelperpgfmathresult ptpgfmathresult pt%
%

newcommandgetMaximumWidth[1]
%
settowidthtextLength@getMaximumWidthpgfinterruptpicture #1endpgfinterruptpicture%
@ifnextcharbgroupgetMaximumWidthHelperthetextLength@getMaximumWidththetextLength@getMaximumWidth%
%

makeatother


Working example used to test the above command:



begindocument

getMaximumWidthcmdOne
getMaximumWidthcmdOnecmdTwo
getMaximumWidthcmdOnecmdTwocmdThree

enddocument


However, when I try to capture the output of getMaximumWidth, it doesn't work as expected.



begindocument

newlengthmaximumWidth
setlengthmaximumWidthgetMaximumWidthcmdOnecmdTwocmdThree
themaximumWidth

enddocument


On the second line, the return value of getMaximumWidth is not captured but instantly printed.

Afterwards I get an error:




! Missing number, treated as
zero.




After that, the third line just prints default value 0.0pt.



What is the proper way to capture the output of getMaximumWidth?



P.S. This is my first time writing Latex document, feel free to point out anything i could've done better.







tikz-pgf lengths






share|improve this question









New contributor




Iskustvo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Iskustvo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Apr 24 at 15:56









David Carlisle

502k4211491897




502k4211491897






New contributor




Iskustvo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Apr 24 at 13:38









IskustvoIskustvo

1183




1183




New contributor




Iskustvo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Iskustvo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Iskustvo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 1





    while @ifnextcharbgroup works you should almost never do it as it results in commands that fail to obey latex syntax conventions. All latex commands have a fixed number of arguments using delimiters and a variable number of optional arguments which use [] delimiters. You have defined a command with optional arguments which is wrong.

    – David Carlisle
    Apr 24 at 14:37












  • macros do not have return values, your getMaximumWidth expands to a series of assignments so is not a length that can be used in setlength, you need to define it to leave a length in some command, say tempresult then use getMaximumWidthcmdOnecmdTwocmdThreesetlengthmaximumWidthtempresult or using a latex-conforming syntax, getMaximumWidthcmdOne,cmdTwo,cmdThreesetlengthmaximumWidthtempresult

    – David Carlisle
    Apr 24 at 15:43












  • That is exactly why pgfmathparse leaves its answer in pgfmathresult

    – David Carlisle
    Apr 24 at 15:45











  • Thanks a lot! I am not able to test everything at the moment, but your solution seems a lot easier and can be used as I intended.

    – Iskustvo
    Apr 24 at 16:00












  • 1





    while @ifnextcharbgroup works you should almost never do it as it results in commands that fail to obey latex syntax conventions. All latex commands have a fixed number of arguments using delimiters and a variable number of optional arguments which use [] delimiters. You have defined a command with optional arguments which is wrong.

    – David Carlisle
    Apr 24 at 14:37












  • macros do not have return values, your getMaximumWidth expands to a series of assignments so is not a length that can be used in setlength, you need to define it to leave a length in some command, say tempresult then use getMaximumWidthcmdOnecmdTwocmdThreesetlengthmaximumWidthtempresult or using a latex-conforming syntax, getMaximumWidthcmdOne,cmdTwo,cmdThreesetlengthmaximumWidthtempresult

    – David Carlisle
    Apr 24 at 15:43












  • That is exactly why pgfmathparse leaves its answer in pgfmathresult

    – David Carlisle
    Apr 24 at 15:45











  • Thanks a lot! I am not able to test everything at the moment, but your solution seems a lot easier and can be used as I intended.

    – Iskustvo
    Apr 24 at 16:00







1




1





while @ifnextcharbgroup works you should almost never do it as it results in commands that fail to obey latex syntax conventions. All latex commands have a fixed number of arguments using delimiters and a variable number of optional arguments which use [] delimiters. You have defined a command with optional arguments which is wrong.

– David Carlisle
Apr 24 at 14:37






while @ifnextcharbgroup works you should almost never do it as it results in commands that fail to obey latex syntax conventions. All latex commands have a fixed number of arguments using delimiters and a variable number of optional arguments which use [] delimiters. You have defined a command with optional arguments which is wrong.

– David Carlisle
Apr 24 at 14:37














macros do not have return values, your getMaximumWidth expands to a series of assignments so is not a length that can be used in setlength, you need to define it to leave a length in some command, say tempresult then use getMaximumWidthcmdOnecmdTwocmdThreesetlengthmaximumWidthtempresult or using a latex-conforming syntax, getMaximumWidthcmdOne,cmdTwo,cmdThreesetlengthmaximumWidthtempresult

– David Carlisle
Apr 24 at 15:43






macros do not have return values, your getMaximumWidth expands to a series of assignments so is not a length that can be used in setlength, you need to define it to leave a length in some command, say tempresult then use getMaximumWidthcmdOnecmdTwocmdThreesetlengthmaximumWidthtempresult or using a latex-conforming syntax, getMaximumWidthcmdOne,cmdTwo,cmdThreesetlengthmaximumWidthtempresult

– David Carlisle
Apr 24 at 15:43














That is exactly why pgfmathparse leaves its answer in pgfmathresult

– David Carlisle
Apr 24 at 15:45





That is exactly why pgfmathparse leaves its answer in pgfmathresult

– David Carlisle
Apr 24 at 15:45













Thanks a lot! I am not able to test everything at the moment, but your solution seems a lot easier and can be used as I intended.

– Iskustvo
Apr 24 at 16:00





Thanks a lot! I am not able to test everything at the moment, but your solution seems a lot easier and can be used as I intended.

– Iskustvo
Apr 24 at 16:00










2 Answers
2






active

oldest

votes


















5














I'd generalize settowidth and, by the way, get also height and depth for free.



documentclassarticle
usepackagexparse

ExplSyntaxOn
NewDocumentCommandsettomaximumwidthmm
% #1 = length, #2 = comma separated list of objects
iskustvo_settomaxdim:Nnn settowidth #1 #2

NewDocumentCommandsettomaximumheightmm
% #1 = length, #2 = comma separated list of objects
iskustvo_settomaxdim:Nnn settoheight #1 #2

NewDocumentCommandsettomaximumdepthmm
% #1 = length, #2 = comma separated list of objects
iskustvo_settomaxdim:Nnn settodepth #1 #2


dim_new:N l__iskustvo_tempa_dim
dim_new:N l__iskustvo_tempb_dim
tl_new:N l__iskustvo_temp_tl

cs_new_protected:Nn iskustvo_settomaxdim:Nnn

dim_zero:N l__iskustvo_tempa_dim
clist_map_variable:nNn #3 l__iskustvo_temp_tl
__iskustvo_measure:N #1
dim_set_eq:NN #2 l__iskustvo_tempa_dim

cs_new_protected:Nn __iskustvo_measure:N

#1l__iskustvo_tempb_diml__iskustvo_temp_tl
dim_set:Nn l__iskustvo_tempa_dim

dim_max:nn l__iskustvo_tempa_dim l__iskustvo_tempb_dim


ExplSyntaxOff

% Font used for writing commands.
defcmdFontfontsize1012selectfont

% Commands.
defcmdOne cmdFont aaa
defcmdTwo cmdFont bbbbb
defcmdThreecmdFont cccc

begindocument

newlengthtest

settomaximumwidthtestcmdOne,cmdTwo,cmdThree
thetest

settomaximumheighttestcmdOne,cmdTwo,cmdThree
thetest

settomaximumdepthtestcmdOne,cmdTwo,cmdThree
thetest

enddocument


enter image description here






share|improve this answer


















  • 2





    Thank you! I won't lie, I have absolutely no idea what you did, but the usage at the end is pretty neat.

    – Iskustvo
    Apr 24 at 17:22











  • I've read a bit and now that I understand what you did with this Elvish syntax, it's even more impressive! Luckily I think I'll just need the width, so I'll dumb it down a little.

    – Iskustvo
    Apr 25 at 19:30



















6














I would write this something like



enter image description here



documentclassarticle

newcommandcmdFontfontsize1012selectfont% this is the default anyway

% Commands.
newcommandcmdOne cmdFont aaa
newcommandcmdTwo cmdFont bbbbb
newcommandcmdThreecmdFont cccc


newlengthmaximumWidth

newcommandgetMaximumWidth[1]%
settowidthmaximumWidthbegintabular@l@#1endtabular

begindocument

getMaximumWidthcmdOne\ cmdTwo\ cmdThree

themaximumWidth

enddocument





share|improve this answer























    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
    );



    );






    Iskustvo is a new contributor. Be nice, and check out our Code of Conduct.









    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f487375%2fhow-to-properly-capture-return-value-of-a-command%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    5














    I'd generalize settowidth and, by the way, get also height and depth for free.



    documentclassarticle
    usepackagexparse

    ExplSyntaxOn
    NewDocumentCommandsettomaximumwidthmm
    % #1 = length, #2 = comma separated list of objects
    iskustvo_settomaxdim:Nnn settowidth #1 #2

    NewDocumentCommandsettomaximumheightmm
    % #1 = length, #2 = comma separated list of objects
    iskustvo_settomaxdim:Nnn settoheight #1 #2

    NewDocumentCommandsettomaximumdepthmm
    % #1 = length, #2 = comma separated list of objects
    iskustvo_settomaxdim:Nnn settodepth #1 #2


    dim_new:N l__iskustvo_tempa_dim
    dim_new:N l__iskustvo_tempb_dim
    tl_new:N l__iskustvo_temp_tl

    cs_new_protected:Nn iskustvo_settomaxdim:Nnn

    dim_zero:N l__iskustvo_tempa_dim
    clist_map_variable:nNn #3 l__iskustvo_temp_tl
    __iskustvo_measure:N #1
    dim_set_eq:NN #2 l__iskustvo_tempa_dim

    cs_new_protected:Nn __iskustvo_measure:N

    #1l__iskustvo_tempb_diml__iskustvo_temp_tl
    dim_set:Nn l__iskustvo_tempa_dim

    dim_max:nn l__iskustvo_tempa_dim l__iskustvo_tempb_dim


    ExplSyntaxOff

    % Font used for writing commands.
    defcmdFontfontsize1012selectfont

    % Commands.
    defcmdOne cmdFont aaa
    defcmdTwo cmdFont bbbbb
    defcmdThreecmdFont cccc

    begindocument

    newlengthtest

    settomaximumwidthtestcmdOne,cmdTwo,cmdThree
    thetest

    settomaximumheighttestcmdOne,cmdTwo,cmdThree
    thetest

    settomaximumdepthtestcmdOne,cmdTwo,cmdThree
    thetest

    enddocument


    enter image description here






    share|improve this answer


















    • 2





      Thank you! I won't lie, I have absolutely no idea what you did, but the usage at the end is pretty neat.

      – Iskustvo
      Apr 24 at 17:22











    • I've read a bit and now that I understand what you did with this Elvish syntax, it's even more impressive! Luckily I think I'll just need the width, so I'll dumb it down a little.

      – Iskustvo
      Apr 25 at 19:30
















    5














    I'd generalize settowidth and, by the way, get also height and depth for free.



    documentclassarticle
    usepackagexparse

    ExplSyntaxOn
    NewDocumentCommandsettomaximumwidthmm
    % #1 = length, #2 = comma separated list of objects
    iskustvo_settomaxdim:Nnn settowidth #1 #2

    NewDocumentCommandsettomaximumheightmm
    % #1 = length, #2 = comma separated list of objects
    iskustvo_settomaxdim:Nnn settoheight #1 #2

    NewDocumentCommandsettomaximumdepthmm
    % #1 = length, #2 = comma separated list of objects
    iskustvo_settomaxdim:Nnn settodepth #1 #2


    dim_new:N l__iskustvo_tempa_dim
    dim_new:N l__iskustvo_tempb_dim
    tl_new:N l__iskustvo_temp_tl

    cs_new_protected:Nn iskustvo_settomaxdim:Nnn

    dim_zero:N l__iskustvo_tempa_dim
    clist_map_variable:nNn #3 l__iskustvo_temp_tl
    __iskustvo_measure:N #1
    dim_set_eq:NN #2 l__iskustvo_tempa_dim

    cs_new_protected:Nn __iskustvo_measure:N

    #1l__iskustvo_tempb_diml__iskustvo_temp_tl
    dim_set:Nn l__iskustvo_tempa_dim

    dim_max:nn l__iskustvo_tempa_dim l__iskustvo_tempb_dim


    ExplSyntaxOff

    % Font used for writing commands.
    defcmdFontfontsize1012selectfont

    % Commands.
    defcmdOne cmdFont aaa
    defcmdTwo cmdFont bbbbb
    defcmdThreecmdFont cccc

    begindocument

    newlengthtest

    settomaximumwidthtestcmdOne,cmdTwo,cmdThree
    thetest

    settomaximumheighttestcmdOne,cmdTwo,cmdThree
    thetest

    settomaximumdepthtestcmdOne,cmdTwo,cmdThree
    thetest

    enddocument


    enter image description here






    share|improve this answer


















    • 2





      Thank you! I won't lie, I have absolutely no idea what you did, but the usage at the end is pretty neat.

      – Iskustvo
      Apr 24 at 17:22











    • I've read a bit and now that I understand what you did with this Elvish syntax, it's even more impressive! Luckily I think I'll just need the width, so I'll dumb it down a little.

      – Iskustvo
      Apr 25 at 19:30














    5












    5








    5







    I'd generalize settowidth and, by the way, get also height and depth for free.



    documentclassarticle
    usepackagexparse

    ExplSyntaxOn
    NewDocumentCommandsettomaximumwidthmm
    % #1 = length, #2 = comma separated list of objects
    iskustvo_settomaxdim:Nnn settowidth #1 #2

    NewDocumentCommandsettomaximumheightmm
    % #1 = length, #2 = comma separated list of objects
    iskustvo_settomaxdim:Nnn settoheight #1 #2

    NewDocumentCommandsettomaximumdepthmm
    % #1 = length, #2 = comma separated list of objects
    iskustvo_settomaxdim:Nnn settodepth #1 #2


    dim_new:N l__iskustvo_tempa_dim
    dim_new:N l__iskustvo_tempb_dim
    tl_new:N l__iskustvo_temp_tl

    cs_new_protected:Nn iskustvo_settomaxdim:Nnn

    dim_zero:N l__iskustvo_tempa_dim
    clist_map_variable:nNn #3 l__iskustvo_temp_tl
    __iskustvo_measure:N #1
    dim_set_eq:NN #2 l__iskustvo_tempa_dim

    cs_new_protected:Nn __iskustvo_measure:N

    #1l__iskustvo_tempb_diml__iskustvo_temp_tl
    dim_set:Nn l__iskustvo_tempa_dim

    dim_max:nn l__iskustvo_tempa_dim l__iskustvo_tempb_dim


    ExplSyntaxOff

    % Font used for writing commands.
    defcmdFontfontsize1012selectfont

    % Commands.
    defcmdOne cmdFont aaa
    defcmdTwo cmdFont bbbbb
    defcmdThreecmdFont cccc

    begindocument

    newlengthtest

    settomaximumwidthtestcmdOne,cmdTwo,cmdThree
    thetest

    settomaximumheighttestcmdOne,cmdTwo,cmdThree
    thetest

    settomaximumdepthtestcmdOne,cmdTwo,cmdThree
    thetest

    enddocument


    enter image description here






    share|improve this answer













    I'd generalize settowidth and, by the way, get also height and depth for free.



    documentclassarticle
    usepackagexparse

    ExplSyntaxOn
    NewDocumentCommandsettomaximumwidthmm
    % #1 = length, #2 = comma separated list of objects
    iskustvo_settomaxdim:Nnn settowidth #1 #2

    NewDocumentCommandsettomaximumheightmm
    % #1 = length, #2 = comma separated list of objects
    iskustvo_settomaxdim:Nnn settoheight #1 #2

    NewDocumentCommandsettomaximumdepthmm
    % #1 = length, #2 = comma separated list of objects
    iskustvo_settomaxdim:Nnn settodepth #1 #2


    dim_new:N l__iskustvo_tempa_dim
    dim_new:N l__iskustvo_tempb_dim
    tl_new:N l__iskustvo_temp_tl

    cs_new_protected:Nn iskustvo_settomaxdim:Nnn

    dim_zero:N l__iskustvo_tempa_dim
    clist_map_variable:nNn #3 l__iskustvo_temp_tl
    __iskustvo_measure:N #1
    dim_set_eq:NN #2 l__iskustvo_tempa_dim

    cs_new_protected:Nn __iskustvo_measure:N

    #1l__iskustvo_tempb_diml__iskustvo_temp_tl
    dim_set:Nn l__iskustvo_tempa_dim

    dim_max:nn l__iskustvo_tempa_dim l__iskustvo_tempb_dim


    ExplSyntaxOff

    % Font used for writing commands.
    defcmdFontfontsize1012selectfont

    % Commands.
    defcmdOne cmdFont aaa
    defcmdTwo cmdFont bbbbb
    defcmdThreecmdFont cccc

    begindocument

    newlengthtest

    settomaximumwidthtestcmdOne,cmdTwo,cmdThree
    thetest

    settomaximumheighttestcmdOne,cmdTwo,cmdThree
    thetest

    settomaximumdepthtestcmdOne,cmdTwo,cmdThree
    thetest

    enddocument


    enter image description here







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Apr 24 at 17:04









    egregegreg

    737k8919393269




    737k8919393269







    • 2





      Thank you! I won't lie, I have absolutely no idea what you did, but the usage at the end is pretty neat.

      – Iskustvo
      Apr 24 at 17:22











    • I've read a bit and now that I understand what you did with this Elvish syntax, it's even more impressive! Luckily I think I'll just need the width, so I'll dumb it down a little.

      – Iskustvo
      Apr 25 at 19:30













    • 2





      Thank you! I won't lie, I have absolutely no idea what you did, but the usage at the end is pretty neat.

      – Iskustvo
      Apr 24 at 17:22











    • I've read a bit and now that I understand what you did with this Elvish syntax, it's even more impressive! Luckily I think I'll just need the width, so I'll dumb it down a little.

      – Iskustvo
      Apr 25 at 19:30








    2




    2





    Thank you! I won't lie, I have absolutely no idea what you did, but the usage at the end is pretty neat.

    – Iskustvo
    Apr 24 at 17:22





    Thank you! I won't lie, I have absolutely no idea what you did, but the usage at the end is pretty neat.

    – Iskustvo
    Apr 24 at 17:22













    I've read a bit and now that I understand what you did with this Elvish syntax, it's even more impressive! Luckily I think I'll just need the width, so I'll dumb it down a little.

    – Iskustvo
    Apr 25 at 19:30






    I've read a bit and now that I understand what you did with this Elvish syntax, it's even more impressive! Luckily I think I'll just need the width, so I'll dumb it down a little.

    – Iskustvo
    Apr 25 at 19:30












    6














    I would write this something like



    enter image description here



    documentclassarticle

    newcommandcmdFontfontsize1012selectfont% this is the default anyway

    % Commands.
    newcommandcmdOne cmdFont aaa
    newcommandcmdTwo cmdFont bbbbb
    newcommandcmdThreecmdFont cccc


    newlengthmaximumWidth

    newcommandgetMaximumWidth[1]%
    settowidthmaximumWidthbegintabular@l@#1endtabular

    begindocument

    getMaximumWidthcmdOne\ cmdTwo\ cmdThree

    themaximumWidth

    enddocument





    share|improve this answer



























      6














      I would write this something like



      enter image description here



      documentclassarticle

      newcommandcmdFontfontsize1012selectfont% this is the default anyway

      % Commands.
      newcommandcmdOne cmdFont aaa
      newcommandcmdTwo cmdFont bbbbb
      newcommandcmdThreecmdFont cccc


      newlengthmaximumWidth

      newcommandgetMaximumWidth[1]%
      settowidthmaximumWidthbegintabular@l@#1endtabular

      begindocument

      getMaximumWidthcmdOne\ cmdTwo\ cmdThree

      themaximumWidth

      enddocument





      share|improve this answer

























        6












        6








        6







        I would write this something like



        enter image description here



        documentclassarticle

        newcommandcmdFontfontsize1012selectfont% this is the default anyway

        % Commands.
        newcommandcmdOne cmdFont aaa
        newcommandcmdTwo cmdFont bbbbb
        newcommandcmdThreecmdFont cccc


        newlengthmaximumWidth

        newcommandgetMaximumWidth[1]%
        settowidthmaximumWidthbegintabular@l@#1endtabular

        begindocument

        getMaximumWidthcmdOne\ cmdTwo\ cmdThree

        themaximumWidth

        enddocument





        share|improve this answer













        I would write this something like



        enter image description here



        documentclassarticle

        newcommandcmdFontfontsize1012selectfont% this is the default anyway

        % Commands.
        newcommandcmdOne cmdFont aaa
        newcommandcmdTwo cmdFont bbbbb
        newcommandcmdThreecmdFont cccc


        newlengthmaximumWidth

        newcommandgetMaximumWidth[1]%
        settowidthmaximumWidthbegintabular@l@#1endtabular

        begindocument

        getMaximumWidthcmdOne\ cmdTwo\ cmdThree

        themaximumWidth

        enddocument






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 24 at 15:54









        David CarlisleDavid Carlisle

        502k4211491897




        502k4211491897




















            Iskustvo is a new contributor. Be nice, and check out our Code of Conduct.









            draft saved

            draft discarded


















            Iskustvo is a new contributor. Be nice, and check out our Code of Conduct.












            Iskustvo is a new contributor. Be nice, and check out our Code of Conduct.











            Iskustvo is a new contributor. Be nice, and check out our Code of Conduct.














            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%2f487375%2fhow-to-properly-capture-return-value-of-a-command%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

            Bulk add to cart function issuecart vs. mini cart issue … rwd themeRedirect Add to cart button to cart pageAdd to cart issue - Magento 2.1The requested Payment Method is not available When creating an orderM2: reason add-to-cart might not function in production modeAdd to cart issue in some android devicesMagento 2 - custom price can not add to subtotal and grand total after add to cartAdd to cart codeIssue with my cart module on pdp and cart pages, just keeps spinningBulk price and quantity update using rest api

            БиармияSxpst500bh2ntaf! 3h2r