rcases with parbox to fit residual space












2















I have the following construct (using package mathtools)



begin{drcases}
Content....
end{drcases} parbox{.53textwidth}{Long Multiline Text Blablabla}


I am using cases to display some long text and I found out that by putting the text into a parbox I can spread it across mutliple lines. But I ended up with manually adjusting the text width (.53textwidth)



And because I have this kind of construct multiple times in my document, I was wondering if it is not possible to automatically calculate the text width, so that I don't need to do this each time by hand.










share|improve this question





























    2















    I have the following construct (using package mathtools)



    begin{drcases}
    Content....
    end{drcases} parbox{.53textwidth}{Long Multiline Text Blablabla}


    I am using cases to display some long text and I found out that by putting the text into a parbox I can spread it across mutliple lines. But I ended up with manually adjusting the text width (.53textwidth)



    And because I have this kind of construct multiple times in my document, I was wondering if it is not possible to automatically calculate the text width, so that I don't need to do this each time by hand.










    share|improve this question



























      2












      2








      2








      I have the following construct (using package mathtools)



      begin{drcases}
      Content....
      end{drcases} parbox{.53textwidth}{Long Multiline Text Blablabla}


      I am using cases to display some long text and I found out that by putting the text into a parbox I can spread it across mutliple lines. But I ended up with manually adjusting the text width (.53textwidth)



      And because I have this kind of construct multiple times in my document, I was wondering if it is not possible to automatically calculate the text width, so that I don't need to do this each time by hand.










      share|improve this question
















      I have the following construct (using package mathtools)



      begin{drcases}
      Content....
      end{drcases} parbox{.53textwidth}{Long Multiline Text Blablabla}


      I am using cases to display some long text and I found out that by putting the text into a parbox I can spread it across mutliple lines. But I ended up with manually adjusting the text width (.53textwidth)



      And because I have this kind of construct multiple times in my document, I was wondering if it is not possible to automatically calculate the text width, so that I don't need to do this each time by hand.







      boxes cases






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jun 27 '15 at 11:24









      lockstep

      192k53592723




      192k53592723










      asked Mar 16 '15 at 11:50









      ax1mx2ax1mx2

      747




      747






















          1 Answer
          1






          active

          oldest

          votes


















          2














          An application of xparse (see edit history for versions of xparse prior to 2019-03-05)



          documentclass{article}
          usepackage{xparse,mathtools}
          usepackage{lipsum}

          ExplSyntaxOn
          NewDocumentEnvironment{xdrcases}{O{4em}mb}
          {
          axmx_xdrcases:nnn { #1 } { #2 } { #3 }
          }
          {}

          box_new:N l_axmx_xdrcases_box
          dim_new:N l_axmx_xdrcases_dim

          cs_new_protected:Npn axmx_xdrcases:nnn #1 #2 #3
          {
          hbox_set:Nn l_axmx_xdrcases_box
          {
          $begin{drcases}#3end{drcases}$
          }
          dim_set:Nn l_axmx_xdrcases_dim
          {
          displaywidth - box_wd:N l_axmx_xdrcases_box - #1
          }
          box_use:N l_axmx_xdrcases_box
          quad
          parbox{l_axmx_xdrcases_dim}{#2}
          }
          ExplSyntaxOff

          begin{document}
          renewcommand{theequation}{1.1.arabic{equation}} % just to show the problem

          lipsum*[2]
          begin{equation*}
          begin{xdrcases}{
          Some long descriptive text, very boring indeed, but
          that should be long enough to require splitting it
          across lines
          }
          frac{1}{2}x & text{if $x$ is rational} \
          -x & text{if $x$ is irrational}
          end{xdrcases}
          end{equation*}
          lipsum*[2]
          begin{equation}
          begin{xdrcases}[6em]{
          Some long descriptive text, very boring indeed, but
          that should be long enough to require splitting it
          across lines
          }
          frac{1}{2}x & text{if $x$ is rational} \
          -x & text{if $x$ is irrational}
          end{xdrcases}
          end{equation}
          lipsum[4]

          end{document}


          The optional argument (default 4em) sets the space to be left empty; as you see, in case of long equation numbers 4em can be too small, so one can act consequently.



          enter image description here



          You might want to examine the following variant, where the text to be put on the side comes after the sidecondition macro; if sidecondition doesn't appear, the environment is the same as drcases.



          documentclass{article}
          usepackage{xparse,mathtools}
          usepackage{lipsum}

          ExplSyntaxOn
          NewDocumentEnvironment{xdrcases}{O{4em}b}
          {
          axmx_xdrcases:nn { #1 } { #2 }
          }
          {}

          box_new:N l_axmx_xdrcases_box
          dim_new:N l_axmx_xdrcases_dim
          seq_new:N l_axmx_xdrcases_seq

          cs_new_protected:Npn axmx_xdrcases:nn #1 #2
          {
          seq_set_split:Nnn l_axmx_xdrcases_seq { sidecondition } { #2 }
          int_compare:nTF { seq_count:N l_axmx_xdrcases_seq > 1 }
          {% there is a side condition
          hbox_set:Nn l_axmx_xdrcases_box
          {
          $begin{drcases}seq_item:Nn l_axmx_xdrcases_seq { 1 }end{drcases}$
          }
          dim_set:Nn l_axmx_xdrcases_dim
          {
          displaywidth - box_wd:N l_axmx_xdrcases_box - #1
          }
          box_use:N l_axmx_xdrcases_box
          quad
          parbox{l_axmx_xdrcases_dim}{seq_item:Nn l_axmx_xdrcases_seq { 2 }}
          }
          {% no side condition
          begin{drcases}#2end{drcases}
          }
          }
          ExplSyntaxOff

          begin{document}
          renewcommand{theequation}{1.1.arabic{equation}} % just to show the problem

          lipsum*[2]
          begin{equation*}
          begin{xdrcases}
          frac{1}{2}x & text{if $x$ is rational} \
          -x & text{if $x$ is irrational}
          sidecondition
          Some long descriptive text, very boring indeed, but
          that should be long enough to require splitting it
          across lines
          end{xdrcases}
          end{equation*}
          lipsum*[2]
          begin{equation}
          begin{xdrcases}[6em]
          frac{1}{2}x & text{if $x$ is rational} \
          -x & text{if $x$ is irrational}
          sidecondition
          Some long descriptive text, very boring indeed, but
          that should be long enough to require splitting it
          across lines
          end{xdrcases}
          end{equation}
          lipsum*[4]
          begin{equation*}
          begin{xdrcases}
          frac{1}{2}x & text{if $x$ is rational} \
          -x & text{if $x$ is irrational}
          end{xdrcases}
          end{equation*}
          lipsum[3]

          end{document}


          enter image description here






          share|improve this answer


























          • @ax1mx2 Wait a few hours and perhaps an even better version will arrive.

            – egreg
            Mar 16 '15 at 13:34











          • I am so happy that one worked out so well, though it doesn't seem like much of an elegant solution to a newbee like me.

            – ax1mx2
            Mar 16 '15 at 13:43











          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%2f233381%2frcases-with-parbox-to-fit-residual-space%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









          2














          An application of xparse (see edit history for versions of xparse prior to 2019-03-05)



          documentclass{article}
          usepackage{xparse,mathtools}
          usepackage{lipsum}

          ExplSyntaxOn
          NewDocumentEnvironment{xdrcases}{O{4em}mb}
          {
          axmx_xdrcases:nnn { #1 } { #2 } { #3 }
          }
          {}

          box_new:N l_axmx_xdrcases_box
          dim_new:N l_axmx_xdrcases_dim

          cs_new_protected:Npn axmx_xdrcases:nnn #1 #2 #3
          {
          hbox_set:Nn l_axmx_xdrcases_box
          {
          $begin{drcases}#3end{drcases}$
          }
          dim_set:Nn l_axmx_xdrcases_dim
          {
          displaywidth - box_wd:N l_axmx_xdrcases_box - #1
          }
          box_use:N l_axmx_xdrcases_box
          quad
          parbox{l_axmx_xdrcases_dim}{#2}
          }
          ExplSyntaxOff

          begin{document}
          renewcommand{theequation}{1.1.arabic{equation}} % just to show the problem

          lipsum*[2]
          begin{equation*}
          begin{xdrcases}{
          Some long descriptive text, very boring indeed, but
          that should be long enough to require splitting it
          across lines
          }
          frac{1}{2}x & text{if $x$ is rational} \
          -x & text{if $x$ is irrational}
          end{xdrcases}
          end{equation*}
          lipsum*[2]
          begin{equation}
          begin{xdrcases}[6em]{
          Some long descriptive text, very boring indeed, but
          that should be long enough to require splitting it
          across lines
          }
          frac{1}{2}x & text{if $x$ is rational} \
          -x & text{if $x$ is irrational}
          end{xdrcases}
          end{equation}
          lipsum[4]

          end{document}


          The optional argument (default 4em) sets the space to be left empty; as you see, in case of long equation numbers 4em can be too small, so one can act consequently.



          enter image description here



          You might want to examine the following variant, where the text to be put on the side comes after the sidecondition macro; if sidecondition doesn't appear, the environment is the same as drcases.



          documentclass{article}
          usepackage{xparse,mathtools}
          usepackage{lipsum}

          ExplSyntaxOn
          NewDocumentEnvironment{xdrcases}{O{4em}b}
          {
          axmx_xdrcases:nn { #1 } { #2 }
          }
          {}

          box_new:N l_axmx_xdrcases_box
          dim_new:N l_axmx_xdrcases_dim
          seq_new:N l_axmx_xdrcases_seq

          cs_new_protected:Npn axmx_xdrcases:nn #1 #2
          {
          seq_set_split:Nnn l_axmx_xdrcases_seq { sidecondition } { #2 }
          int_compare:nTF { seq_count:N l_axmx_xdrcases_seq > 1 }
          {% there is a side condition
          hbox_set:Nn l_axmx_xdrcases_box
          {
          $begin{drcases}seq_item:Nn l_axmx_xdrcases_seq { 1 }end{drcases}$
          }
          dim_set:Nn l_axmx_xdrcases_dim
          {
          displaywidth - box_wd:N l_axmx_xdrcases_box - #1
          }
          box_use:N l_axmx_xdrcases_box
          quad
          parbox{l_axmx_xdrcases_dim}{seq_item:Nn l_axmx_xdrcases_seq { 2 }}
          }
          {% no side condition
          begin{drcases}#2end{drcases}
          }
          }
          ExplSyntaxOff

          begin{document}
          renewcommand{theequation}{1.1.arabic{equation}} % just to show the problem

          lipsum*[2]
          begin{equation*}
          begin{xdrcases}
          frac{1}{2}x & text{if $x$ is rational} \
          -x & text{if $x$ is irrational}
          sidecondition
          Some long descriptive text, very boring indeed, but
          that should be long enough to require splitting it
          across lines
          end{xdrcases}
          end{equation*}
          lipsum*[2]
          begin{equation}
          begin{xdrcases}[6em]
          frac{1}{2}x & text{if $x$ is rational} \
          -x & text{if $x$ is irrational}
          sidecondition
          Some long descriptive text, very boring indeed, but
          that should be long enough to require splitting it
          across lines
          end{xdrcases}
          end{equation}
          lipsum*[4]
          begin{equation*}
          begin{xdrcases}
          frac{1}{2}x & text{if $x$ is rational} \
          -x & text{if $x$ is irrational}
          end{xdrcases}
          end{equation*}
          lipsum[3]

          end{document}


          enter image description here






          share|improve this answer


























          • @ax1mx2 Wait a few hours and perhaps an even better version will arrive.

            – egreg
            Mar 16 '15 at 13:34











          • I am so happy that one worked out so well, though it doesn't seem like much of an elegant solution to a newbee like me.

            – ax1mx2
            Mar 16 '15 at 13:43
















          2














          An application of xparse (see edit history for versions of xparse prior to 2019-03-05)



          documentclass{article}
          usepackage{xparse,mathtools}
          usepackage{lipsum}

          ExplSyntaxOn
          NewDocumentEnvironment{xdrcases}{O{4em}mb}
          {
          axmx_xdrcases:nnn { #1 } { #2 } { #3 }
          }
          {}

          box_new:N l_axmx_xdrcases_box
          dim_new:N l_axmx_xdrcases_dim

          cs_new_protected:Npn axmx_xdrcases:nnn #1 #2 #3
          {
          hbox_set:Nn l_axmx_xdrcases_box
          {
          $begin{drcases}#3end{drcases}$
          }
          dim_set:Nn l_axmx_xdrcases_dim
          {
          displaywidth - box_wd:N l_axmx_xdrcases_box - #1
          }
          box_use:N l_axmx_xdrcases_box
          quad
          parbox{l_axmx_xdrcases_dim}{#2}
          }
          ExplSyntaxOff

          begin{document}
          renewcommand{theequation}{1.1.arabic{equation}} % just to show the problem

          lipsum*[2]
          begin{equation*}
          begin{xdrcases}{
          Some long descriptive text, very boring indeed, but
          that should be long enough to require splitting it
          across lines
          }
          frac{1}{2}x & text{if $x$ is rational} \
          -x & text{if $x$ is irrational}
          end{xdrcases}
          end{equation*}
          lipsum*[2]
          begin{equation}
          begin{xdrcases}[6em]{
          Some long descriptive text, very boring indeed, but
          that should be long enough to require splitting it
          across lines
          }
          frac{1}{2}x & text{if $x$ is rational} \
          -x & text{if $x$ is irrational}
          end{xdrcases}
          end{equation}
          lipsum[4]

          end{document}


          The optional argument (default 4em) sets the space to be left empty; as you see, in case of long equation numbers 4em can be too small, so one can act consequently.



          enter image description here



          You might want to examine the following variant, where the text to be put on the side comes after the sidecondition macro; if sidecondition doesn't appear, the environment is the same as drcases.



          documentclass{article}
          usepackage{xparse,mathtools}
          usepackage{lipsum}

          ExplSyntaxOn
          NewDocumentEnvironment{xdrcases}{O{4em}b}
          {
          axmx_xdrcases:nn { #1 } { #2 }
          }
          {}

          box_new:N l_axmx_xdrcases_box
          dim_new:N l_axmx_xdrcases_dim
          seq_new:N l_axmx_xdrcases_seq

          cs_new_protected:Npn axmx_xdrcases:nn #1 #2
          {
          seq_set_split:Nnn l_axmx_xdrcases_seq { sidecondition } { #2 }
          int_compare:nTF { seq_count:N l_axmx_xdrcases_seq > 1 }
          {% there is a side condition
          hbox_set:Nn l_axmx_xdrcases_box
          {
          $begin{drcases}seq_item:Nn l_axmx_xdrcases_seq { 1 }end{drcases}$
          }
          dim_set:Nn l_axmx_xdrcases_dim
          {
          displaywidth - box_wd:N l_axmx_xdrcases_box - #1
          }
          box_use:N l_axmx_xdrcases_box
          quad
          parbox{l_axmx_xdrcases_dim}{seq_item:Nn l_axmx_xdrcases_seq { 2 }}
          }
          {% no side condition
          begin{drcases}#2end{drcases}
          }
          }
          ExplSyntaxOff

          begin{document}
          renewcommand{theequation}{1.1.arabic{equation}} % just to show the problem

          lipsum*[2]
          begin{equation*}
          begin{xdrcases}
          frac{1}{2}x & text{if $x$ is rational} \
          -x & text{if $x$ is irrational}
          sidecondition
          Some long descriptive text, very boring indeed, but
          that should be long enough to require splitting it
          across lines
          end{xdrcases}
          end{equation*}
          lipsum*[2]
          begin{equation}
          begin{xdrcases}[6em]
          frac{1}{2}x & text{if $x$ is rational} \
          -x & text{if $x$ is irrational}
          sidecondition
          Some long descriptive text, very boring indeed, but
          that should be long enough to require splitting it
          across lines
          end{xdrcases}
          end{equation}
          lipsum*[4]
          begin{equation*}
          begin{xdrcases}
          frac{1}{2}x & text{if $x$ is rational} \
          -x & text{if $x$ is irrational}
          end{xdrcases}
          end{equation*}
          lipsum[3]

          end{document}


          enter image description here






          share|improve this answer


























          • @ax1mx2 Wait a few hours and perhaps an even better version will arrive.

            – egreg
            Mar 16 '15 at 13:34











          • I am so happy that one worked out so well, though it doesn't seem like much of an elegant solution to a newbee like me.

            – ax1mx2
            Mar 16 '15 at 13:43














          2












          2








          2







          An application of xparse (see edit history for versions of xparse prior to 2019-03-05)



          documentclass{article}
          usepackage{xparse,mathtools}
          usepackage{lipsum}

          ExplSyntaxOn
          NewDocumentEnvironment{xdrcases}{O{4em}mb}
          {
          axmx_xdrcases:nnn { #1 } { #2 } { #3 }
          }
          {}

          box_new:N l_axmx_xdrcases_box
          dim_new:N l_axmx_xdrcases_dim

          cs_new_protected:Npn axmx_xdrcases:nnn #1 #2 #3
          {
          hbox_set:Nn l_axmx_xdrcases_box
          {
          $begin{drcases}#3end{drcases}$
          }
          dim_set:Nn l_axmx_xdrcases_dim
          {
          displaywidth - box_wd:N l_axmx_xdrcases_box - #1
          }
          box_use:N l_axmx_xdrcases_box
          quad
          parbox{l_axmx_xdrcases_dim}{#2}
          }
          ExplSyntaxOff

          begin{document}
          renewcommand{theequation}{1.1.arabic{equation}} % just to show the problem

          lipsum*[2]
          begin{equation*}
          begin{xdrcases}{
          Some long descriptive text, very boring indeed, but
          that should be long enough to require splitting it
          across lines
          }
          frac{1}{2}x & text{if $x$ is rational} \
          -x & text{if $x$ is irrational}
          end{xdrcases}
          end{equation*}
          lipsum*[2]
          begin{equation}
          begin{xdrcases}[6em]{
          Some long descriptive text, very boring indeed, but
          that should be long enough to require splitting it
          across lines
          }
          frac{1}{2}x & text{if $x$ is rational} \
          -x & text{if $x$ is irrational}
          end{xdrcases}
          end{equation}
          lipsum[4]

          end{document}


          The optional argument (default 4em) sets the space to be left empty; as you see, in case of long equation numbers 4em can be too small, so one can act consequently.



          enter image description here



          You might want to examine the following variant, where the text to be put on the side comes after the sidecondition macro; if sidecondition doesn't appear, the environment is the same as drcases.



          documentclass{article}
          usepackage{xparse,mathtools}
          usepackage{lipsum}

          ExplSyntaxOn
          NewDocumentEnvironment{xdrcases}{O{4em}b}
          {
          axmx_xdrcases:nn { #1 } { #2 }
          }
          {}

          box_new:N l_axmx_xdrcases_box
          dim_new:N l_axmx_xdrcases_dim
          seq_new:N l_axmx_xdrcases_seq

          cs_new_protected:Npn axmx_xdrcases:nn #1 #2
          {
          seq_set_split:Nnn l_axmx_xdrcases_seq { sidecondition } { #2 }
          int_compare:nTF { seq_count:N l_axmx_xdrcases_seq > 1 }
          {% there is a side condition
          hbox_set:Nn l_axmx_xdrcases_box
          {
          $begin{drcases}seq_item:Nn l_axmx_xdrcases_seq { 1 }end{drcases}$
          }
          dim_set:Nn l_axmx_xdrcases_dim
          {
          displaywidth - box_wd:N l_axmx_xdrcases_box - #1
          }
          box_use:N l_axmx_xdrcases_box
          quad
          parbox{l_axmx_xdrcases_dim}{seq_item:Nn l_axmx_xdrcases_seq { 2 }}
          }
          {% no side condition
          begin{drcases}#2end{drcases}
          }
          }
          ExplSyntaxOff

          begin{document}
          renewcommand{theequation}{1.1.arabic{equation}} % just to show the problem

          lipsum*[2]
          begin{equation*}
          begin{xdrcases}
          frac{1}{2}x & text{if $x$ is rational} \
          -x & text{if $x$ is irrational}
          sidecondition
          Some long descriptive text, very boring indeed, but
          that should be long enough to require splitting it
          across lines
          end{xdrcases}
          end{equation*}
          lipsum*[2]
          begin{equation}
          begin{xdrcases}[6em]
          frac{1}{2}x & text{if $x$ is rational} \
          -x & text{if $x$ is irrational}
          sidecondition
          Some long descriptive text, very boring indeed, but
          that should be long enough to require splitting it
          across lines
          end{xdrcases}
          end{equation}
          lipsum*[4]
          begin{equation*}
          begin{xdrcases}
          frac{1}{2}x & text{if $x$ is rational} \
          -x & text{if $x$ is irrational}
          end{xdrcases}
          end{equation*}
          lipsum[3]

          end{document}


          enter image description here






          share|improve this answer















          An application of xparse (see edit history for versions of xparse prior to 2019-03-05)



          documentclass{article}
          usepackage{xparse,mathtools}
          usepackage{lipsum}

          ExplSyntaxOn
          NewDocumentEnvironment{xdrcases}{O{4em}mb}
          {
          axmx_xdrcases:nnn { #1 } { #2 } { #3 }
          }
          {}

          box_new:N l_axmx_xdrcases_box
          dim_new:N l_axmx_xdrcases_dim

          cs_new_protected:Npn axmx_xdrcases:nnn #1 #2 #3
          {
          hbox_set:Nn l_axmx_xdrcases_box
          {
          $begin{drcases}#3end{drcases}$
          }
          dim_set:Nn l_axmx_xdrcases_dim
          {
          displaywidth - box_wd:N l_axmx_xdrcases_box - #1
          }
          box_use:N l_axmx_xdrcases_box
          quad
          parbox{l_axmx_xdrcases_dim}{#2}
          }
          ExplSyntaxOff

          begin{document}
          renewcommand{theequation}{1.1.arabic{equation}} % just to show the problem

          lipsum*[2]
          begin{equation*}
          begin{xdrcases}{
          Some long descriptive text, very boring indeed, but
          that should be long enough to require splitting it
          across lines
          }
          frac{1}{2}x & text{if $x$ is rational} \
          -x & text{if $x$ is irrational}
          end{xdrcases}
          end{equation*}
          lipsum*[2]
          begin{equation}
          begin{xdrcases}[6em]{
          Some long descriptive text, very boring indeed, but
          that should be long enough to require splitting it
          across lines
          }
          frac{1}{2}x & text{if $x$ is rational} \
          -x & text{if $x$ is irrational}
          end{xdrcases}
          end{equation}
          lipsum[4]

          end{document}


          The optional argument (default 4em) sets the space to be left empty; as you see, in case of long equation numbers 4em can be too small, so one can act consequently.



          enter image description here



          You might want to examine the following variant, where the text to be put on the side comes after the sidecondition macro; if sidecondition doesn't appear, the environment is the same as drcases.



          documentclass{article}
          usepackage{xparse,mathtools}
          usepackage{lipsum}

          ExplSyntaxOn
          NewDocumentEnvironment{xdrcases}{O{4em}b}
          {
          axmx_xdrcases:nn { #1 } { #2 }
          }
          {}

          box_new:N l_axmx_xdrcases_box
          dim_new:N l_axmx_xdrcases_dim
          seq_new:N l_axmx_xdrcases_seq

          cs_new_protected:Npn axmx_xdrcases:nn #1 #2
          {
          seq_set_split:Nnn l_axmx_xdrcases_seq { sidecondition } { #2 }
          int_compare:nTF { seq_count:N l_axmx_xdrcases_seq > 1 }
          {% there is a side condition
          hbox_set:Nn l_axmx_xdrcases_box
          {
          $begin{drcases}seq_item:Nn l_axmx_xdrcases_seq { 1 }end{drcases}$
          }
          dim_set:Nn l_axmx_xdrcases_dim
          {
          displaywidth - box_wd:N l_axmx_xdrcases_box - #1
          }
          box_use:N l_axmx_xdrcases_box
          quad
          parbox{l_axmx_xdrcases_dim}{seq_item:Nn l_axmx_xdrcases_seq { 2 }}
          }
          {% no side condition
          begin{drcases}#2end{drcases}
          }
          }
          ExplSyntaxOff

          begin{document}
          renewcommand{theequation}{1.1.arabic{equation}} % just to show the problem

          lipsum*[2]
          begin{equation*}
          begin{xdrcases}
          frac{1}{2}x & text{if $x$ is rational} \
          -x & text{if $x$ is irrational}
          sidecondition
          Some long descriptive text, very boring indeed, but
          that should be long enough to require splitting it
          across lines
          end{xdrcases}
          end{equation*}
          lipsum*[2]
          begin{equation}
          begin{xdrcases}[6em]
          frac{1}{2}x & text{if $x$ is rational} \
          -x & text{if $x$ is irrational}
          sidecondition
          Some long descriptive text, very boring indeed, but
          that should be long enough to require splitting it
          across lines
          end{xdrcases}
          end{equation}
          lipsum*[4]
          begin{equation*}
          begin{xdrcases}
          frac{1}{2}x & text{if $x$ is rational} \
          -x & text{if $x$ is irrational}
          end{xdrcases}
          end{equation*}
          lipsum[3]

          end{document}


          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 9 at 15:47

























          answered Mar 16 '15 at 13:18









          egregegreg

          727k8819223231




          727k8819223231













          • @ax1mx2 Wait a few hours and perhaps an even better version will arrive.

            – egreg
            Mar 16 '15 at 13:34











          • I am so happy that one worked out so well, though it doesn't seem like much of an elegant solution to a newbee like me.

            – ax1mx2
            Mar 16 '15 at 13:43



















          • @ax1mx2 Wait a few hours and perhaps an even better version will arrive.

            – egreg
            Mar 16 '15 at 13:34











          • I am so happy that one worked out so well, though it doesn't seem like much of an elegant solution to a newbee like me.

            – ax1mx2
            Mar 16 '15 at 13:43

















          @ax1mx2 Wait a few hours and perhaps an even better version will arrive.

          – egreg
          Mar 16 '15 at 13:34





          @ax1mx2 Wait a few hours and perhaps an even better version will arrive.

          – egreg
          Mar 16 '15 at 13:34













          I am so happy that one worked out so well, though it doesn't seem like much of an elegant solution to a newbee like me.

          – ax1mx2
          Mar 16 '15 at 13:43





          I am so happy that one worked out so well, though it doesn't seem like much of an elegant solution to a newbee like me.

          – ax1mx2
          Mar 16 '15 at 13:43


















          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%2f233381%2frcases-with-parbox-to-fit-residual-space%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

          Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

          ComboBox Display Member on multiple fields

          Is it possible to collect Nectar points via Trainline?