Why conflict between mathtools and Gonzalo's solution for auto-adjusting description environment?











up vote
7
down vote

favorite
1












Gonzalo Medina provided a nifty solution to "Automatically set description list labelwidth based on widest label?." (The goal was to define a description environment where the item text is automatically indented to the width of the widest label.)



I could replicate its success on a standalone basis, but when I incorporated it into my standard set of packages, it no longer produced the desired results. By a process of elimination, I discovered that simply loading the mathtools package was sufficient to cause the problem.



I don't know where to begin to search for the conflict or a workaround, but I'm hoping someone with more experience, with mathtools in particular, would spot it quickly.



Below is the MWE, straight out of Gonzalo's solution, except that I've inserted a commented-out usepackage{mathtools}. (I've experimented with the order of loading mathtools but nothing solved the problem.)



Without mathtools, the proper output looks like:
enter image description here



With mathtools, the improper output looks like:
enter image description here



documentclass{article}
usepackage{enumitem}
usepackage{environ}
%usepackage{mathtools}

newlengthwidest
makeatletter
NewEnviron{ldescription}{%
vbox{%
globalsetlengthwidest{0pt}%
defitem[##1]{%
settowidth@tempdima{textbf{##1}}%
ifdim@tempdima>widestglobalsetlengthwidest{@tempdima}fi%
}%
setbox0=hbox{BODY}%
}
begin{description}[
leftmargin=dimexprwidest+0.5emrelax,
labelindent=0pt,
labelwidth=widest]
BODY
end{description}%
}
makeatother

begin{document}

begin{ldescription}
item[Short] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
item[A really really long label] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
end{ldescription}

begin{ldescription}
item[Short] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
item[A medium label] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
end{ldescription}

end{document}









share|improve this question




























    up vote
    7
    down vote

    favorite
    1












    Gonzalo Medina provided a nifty solution to "Automatically set description list labelwidth based on widest label?." (The goal was to define a description environment where the item text is automatically indented to the width of the widest label.)



    I could replicate its success on a standalone basis, but when I incorporated it into my standard set of packages, it no longer produced the desired results. By a process of elimination, I discovered that simply loading the mathtools package was sufficient to cause the problem.



    I don't know where to begin to search for the conflict or a workaround, but I'm hoping someone with more experience, with mathtools in particular, would spot it quickly.



    Below is the MWE, straight out of Gonzalo's solution, except that I've inserted a commented-out usepackage{mathtools}. (I've experimented with the order of loading mathtools but nothing solved the problem.)



    Without mathtools, the proper output looks like:
    enter image description here



    With mathtools, the improper output looks like:
    enter image description here



    documentclass{article}
    usepackage{enumitem}
    usepackage{environ}
    %usepackage{mathtools}

    newlengthwidest
    makeatletter
    NewEnviron{ldescription}{%
    vbox{%
    globalsetlengthwidest{0pt}%
    defitem[##1]{%
    settowidth@tempdima{textbf{##1}}%
    ifdim@tempdima>widestglobalsetlengthwidest{@tempdima}fi%
    }%
    setbox0=hbox{BODY}%
    }
    begin{description}[
    leftmargin=dimexprwidest+0.5emrelax,
    labelindent=0pt,
    labelwidth=widest]
    BODY
    end{description}%
    }
    makeatother

    begin{document}

    begin{ldescription}
    item[Short] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
    item[A really really long label] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
    end{ldescription}

    begin{ldescription}
    item[Short] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
    item[A medium label] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
    end{ldescription}

    end{document}









    share|improve this question


























      up vote
      7
      down vote

      favorite
      1









      up vote
      7
      down vote

      favorite
      1






      1





      Gonzalo Medina provided a nifty solution to "Automatically set description list labelwidth based on widest label?." (The goal was to define a description environment where the item text is automatically indented to the width of the widest label.)



      I could replicate its success on a standalone basis, but when I incorporated it into my standard set of packages, it no longer produced the desired results. By a process of elimination, I discovered that simply loading the mathtools package was sufficient to cause the problem.



      I don't know where to begin to search for the conflict or a workaround, but I'm hoping someone with more experience, with mathtools in particular, would spot it quickly.



      Below is the MWE, straight out of Gonzalo's solution, except that I've inserted a commented-out usepackage{mathtools}. (I've experimented with the order of loading mathtools but nothing solved the problem.)



      Without mathtools, the proper output looks like:
      enter image description here



      With mathtools, the improper output looks like:
      enter image description here



      documentclass{article}
      usepackage{enumitem}
      usepackage{environ}
      %usepackage{mathtools}

      newlengthwidest
      makeatletter
      NewEnviron{ldescription}{%
      vbox{%
      globalsetlengthwidest{0pt}%
      defitem[##1]{%
      settowidth@tempdima{textbf{##1}}%
      ifdim@tempdima>widestglobalsetlengthwidest{@tempdima}fi%
      }%
      setbox0=hbox{BODY}%
      }
      begin{description}[
      leftmargin=dimexprwidest+0.5emrelax,
      labelindent=0pt,
      labelwidth=widest]
      BODY
      end{description}%
      }
      makeatother

      begin{document}

      begin{ldescription}
      item[Short] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
      item[A really really long label] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
      end{ldescription}

      begin{ldescription}
      item[Short] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
      item[A medium label] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
      end{ldescription}

      end{document}









      share|improve this question















      Gonzalo Medina provided a nifty solution to "Automatically set description list labelwidth based on widest label?." (The goal was to define a description environment where the item text is automatically indented to the width of the widest label.)



      I could replicate its success on a standalone basis, but when I incorporated it into my standard set of packages, it no longer produced the desired results. By a process of elimination, I discovered that simply loading the mathtools package was sufficient to cause the problem.



      I don't know where to begin to search for the conflict or a workaround, but I'm hoping someone with more experience, with mathtools in particular, would spot it quickly.



      Below is the MWE, straight out of Gonzalo's solution, except that I've inserted a commented-out usepackage{mathtools}. (I've experimented with the order of loading mathtools but nothing solved the problem.)



      Without mathtools, the proper output looks like:
      enter image description here



      With mathtools, the improper output looks like:
      enter image description here



      documentclass{article}
      usepackage{enumitem}
      usepackage{environ}
      %usepackage{mathtools}

      newlengthwidest
      makeatletter
      NewEnviron{ldescription}{%
      vbox{%
      globalsetlengthwidest{0pt}%
      defitem[##1]{%
      settowidth@tempdima{textbf{##1}}%
      ifdim@tempdima>widestglobalsetlengthwidest{@tempdima}fi%
      }%
      setbox0=hbox{BODY}%
      }
      begin{description}[
      leftmargin=dimexprwidest+0.5emrelax,
      labelindent=0pt,
      labelwidth=widest]
      BODY
      end{description}%
      }
      makeatother

      begin{document}

      begin{ldescription}
      item[Short] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
      item[A really really long label] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
      end{ldescription}

      begin{ldescription}
      item[Short] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
      item[A medium label] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
      end{ldescription}

      end{document}






      math-mode lists description calc






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 21 at 14:37

























      asked Nov 21 at 3:15









      Jim Ratliff

      4391410




      4391410






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          8
          down vote



          accepted










          After loading the length widest gets "reseted". This is not really triggered by mathtools but by calc, which gets loaded by mathtools, as explained in this great answer. It is then easy to solve the problem: set the distance using = rather than setlength.



          documentclass{article}
          usepackage{enumitem}
          usepackage{environ}
          usepackage{mathtools}

          newlengthwidest
          makeatletter
          NewEnviron{ldescription}{%
          vbox{%
          globalwidest=0pt%
          defitem[##1]{%
          settowidth@tempdimb{textbf{##1}}%
          ifdim@tempdima>widestrelax
          globalwidest=@tempdimbfi%
          }%
          setbox0=hbox{BODY}%
          }
          begin{description}[
          leftmargin=dimexprwidest+0.5emrelax,
          labelindent=0pt,
          labelwidth=widest]
          BODY
          end{description}%
          }
          makeatother

          begin{document}

          begin{ldescription}
          item[Short] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
          item[A really really long label] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
          end{ldescription}

          begin{ldescription}
          item[Short] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
          item[A medium label] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
          end{ldescription}

          end{document}


          enter image description here






          share|improve this answer



















          • 1




            I revised this answer quite a bit because I learned a lot from egreg's nice answer. Imagine how much I could learn from egreg's question, if he had one. ;-)
            – marmot
            Nov 21 at 5:46






          • 1




            Wow. Super answer; both very interesting. (I keep discovering, mostly negatively, that commands are redefining things I rely on without my knowledge!) And very helpful. This saves the enterprise just by changing a few characters.
            – Jim Ratliff
            Nov 21 at 5:52






          • 1




            @JimRatliff Thanks! I actually did not know any of this, so thanks a lot for this really nice question! (How did I get on track? I just added typeouts at many positions of your/Gonzalo's code, which revealed that widest got resetted. Then I did a google search with site:tex.stackexchange.com mathtools setlength, which lead me right to egregs answer. This kind of strategy, i.e. typeouts and google searches with site:tex.stackexchange.com, can sometimes be useful.)
            – marmot
            Nov 21 at 5:59











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "85"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: 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%2f461056%2fwhy-conflict-between-mathtools-and-gonzalos-solution-for-auto-adjusting-descrip%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








          up vote
          8
          down vote



          accepted










          After loading the length widest gets "reseted". This is not really triggered by mathtools but by calc, which gets loaded by mathtools, as explained in this great answer. It is then easy to solve the problem: set the distance using = rather than setlength.



          documentclass{article}
          usepackage{enumitem}
          usepackage{environ}
          usepackage{mathtools}

          newlengthwidest
          makeatletter
          NewEnviron{ldescription}{%
          vbox{%
          globalwidest=0pt%
          defitem[##1]{%
          settowidth@tempdimb{textbf{##1}}%
          ifdim@tempdima>widestrelax
          globalwidest=@tempdimbfi%
          }%
          setbox0=hbox{BODY}%
          }
          begin{description}[
          leftmargin=dimexprwidest+0.5emrelax,
          labelindent=0pt,
          labelwidth=widest]
          BODY
          end{description}%
          }
          makeatother

          begin{document}

          begin{ldescription}
          item[Short] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
          item[A really really long label] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
          end{ldescription}

          begin{ldescription}
          item[Short] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
          item[A medium label] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
          end{ldescription}

          end{document}


          enter image description here






          share|improve this answer



















          • 1




            I revised this answer quite a bit because I learned a lot from egreg's nice answer. Imagine how much I could learn from egreg's question, if he had one. ;-)
            – marmot
            Nov 21 at 5:46






          • 1




            Wow. Super answer; both very interesting. (I keep discovering, mostly negatively, that commands are redefining things I rely on without my knowledge!) And very helpful. This saves the enterprise just by changing a few characters.
            – Jim Ratliff
            Nov 21 at 5:52






          • 1




            @JimRatliff Thanks! I actually did not know any of this, so thanks a lot for this really nice question! (How did I get on track? I just added typeouts at many positions of your/Gonzalo's code, which revealed that widest got resetted. Then I did a google search with site:tex.stackexchange.com mathtools setlength, which lead me right to egregs answer. This kind of strategy, i.e. typeouts and google searches with site:tex.stackexchange.com, can sometimes be useful.)
            – marmot
            Nov 21 at 5:59















          up vote
          8
          down vote



          accepted










          After loading the length widest gets "reseted". This is not really triggered by mathtools but by calc, which gets loaded by mathtools, as explained in this great answer. It is then easy to solve the problem: set the distance using = rather than setlength.



          documentclass{article}
          usepackage{enumitem}
          usepackage{environ}
          usepackage{mathtools}

          newlengthwidest
          makeatletter
          NewEnviron{ldescription}{%
          vbox{%
          globalwidest=0pt%
          defitem[##1]{%
          settowidth@tempdimb{textbf{##1}}%
          ifdim@tempdima>widestrelax
          globalwidest=@tempdimbfi%
          }%
          setbox0=hbox{BODY}%
          }
          begin{description}[
          leftmargin=dimexprwidest+0.5emrelax,
          labelindent=0pt,
          labelwidth=widest]
          BODY
          end{description}%
          }
          makeatother

          begin{document}

          begin{ldescription}
          item[Short] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
          item[A really really long label] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
          end{ldescription}

          begin{ldescription}
          item[Short] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
          item[A medium label] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
          end{ldescription}

          end{document}


          enter image description here






          share|improve this answer



















          • 1




            I revised this answer quite a bit because I learned a lot from egreg's nice answer. Imagine how much I could learn from egreg's question, if he had one. ;-)
            – marmot
            Nov 21 at 5:46






          • 1




            Wow. Super answer; both very interesting. (I keep discovering, mostly negatively, that commands are redefining things I rely on without my knowledge!) And very helpful. This saves the enterprise just by changing a few characters.
            – Jim Ratliff
            Nov 21 at 5:52






          • 1




            @JimRatliff Thanks! I actually did not know any of this, so thanks a lot for this really nice question! (How did I get on track? I just added typeouts at many positions of your/Gonzalo's code, which revealed that widest got resetted. Then I did a google search with site:tex.stackexchange.com mathtools setlength, which lead me right to egregs answer. This kind of strategy, i.e. typeouts and google searches with site:tex.stackexchange.com, can sometimes be useful.)
            – marmot
            Nov 21 at 5:59













          up vote
          8
          down vote



          accepted







          up vote
          8
          down vote



          accepted






          After loading the length widest gets "reseted". This is not really triggered by mathtools but by calc, which gets loaded by mathtools, as explained in this great answer. It is then easy to solve the problem: set the distance using = rather than setlength.



          documentclass{article}
          usepackage{enumitem}
          usepackage{environ}
          usepackage{mathtools}

          newlengthwidest
          makeatletter
          NewEnviron{ldescription}{%
          vbox{%
          globalwidest=0pt%
          defitem[##1]{%
          settowidth@tempdimb{textbf{##1}}%
          ifdim@tempdima>widestrelax
          globalwidest=@tempdimbfi%
          }%
          setbox0=hbox{BODY}%
          }
          begin{description}[
          leftmargin=dimexprwidest+0.5emrelax,
          labelindent=0pt,
          labelwidth=widest]
          BODY
          end{description}%
          }
          makeatother

          begin{document}

          begin{ldescription}
          item[Short] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
          item[A really really long label] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
          end{ldescription}

          begin{ldescription}
          item[Short] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
          item[A medium label] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
          end{ldescription}

          end{document}


          enter image description here






          share|improve this answer














          After loading the length widest gets "reseted". This is not really triggered by mathtools but by calc, which gets loaded by mathtools, as explained in this great answer. It is then easy to solve the problem: set the distance using = rather than setlength.



          documentclass{article}
          usepackage{enumitem}
          usepackage{environ}
          usepackage{mathtools}

          newlengthwidest
          makeatletter
          NewEnviron{ldescription}{%
          vbox{%
          globalwidest=0pt%
          defitem[##1]{%
          settowidth@tempdimb{textbf{##1}}%
          ifdim@tempdima>widestrelax
          globalwidest=@tempdimbfi%
          }%
          setbox0=hbox{BODY}%
          }
          begin{description}[
          leftmargin=dimexprwidest+0.5emrelax,
          labelindent=0pt,
          labelwidth=widest]
          BODY
          end{description}%
          }
          makeatother

          begin{document}

          begin{ldescription}
          item[Short] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
          item[A really really long label] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
          end{ldescription}

          begin{ldescription}
          item[Short] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
          item[A medium label] text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
          end{ldescription}

          end{document}


          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 21 at 5:44

























          answered Nov 21 at 5:38









          marmot

          78.6k487166




          78.6k487166








          • 1




            I revised this answer quite a bit because I learned a lot from egreg's nice answer. Imagine how much I could learn from egreg's question, if he had one. ;-)
            – marmot
            Nov 21 at 5:46






          • 1




            Wow. Super answer; both very interesting. (I keep discovering, mostly negatively, that commands are redefining things I rely on without my knowledge!) And very helpful. This saves the enterprise just by changing a few characters.
            – Jim Ratliff
            Nov 21 at 5:52






          • 1




            @JimRatliff Thanks! I actually did not know any of this, so thanks a lot for this really nice question! (How did I get on track? I just added typeouts at many positions of your/Gonzalo's code, which revealed that widest got resetted. Then I did a google search with site:tex.stackexchange.com mathtools setlength, which lead me right to egregs answer. This kind of strategy, i.e. typeouts and google searches with site:tex.stackexchange.com, can sometimes be useful.)
            – marmot
            Nov 21 at 5:59














          • 1




            I revised this answer quite a bit because I learned a lot from egreg's nice answer. Imagine how much I could learn from egreg's question, if he had one. ;-)
            – marmot
            Nov 21 at 5:46






          • 1




            Wow. Super answer; both very interesting. (I keep discovering, mostly negatively, that commands are redefining things I rely on without my knowledge!) And very helpful. This saves the enterprise just by changing a few characters.
            – Jim Ratliff
            Nov 21 at 5:52






          • 1




            @JimRatliff Thanks! I actually did not know any of this, so thanks a lot for this really nice question! (How did I get on track? I just added typeouts at many positions of your/Gonzalo's code, which revealed that widest got resetted. Then I did a google search with site:tex.stackexchange.com mathtools setlength, which lead me right to egregs answer. This kind of strategy, i.e. typeouts and google searches with site:tex.stackexchange.com, can sometimes be useful.)
            – marmot
            Nov 21 at 5:59








          1




          1




          I revised this answer quite a bit because I learned a lot from egreg's nice answer. Imagine how much I could learn from egreg's question, if he had one. ;-)
          – marmot
          Nov 21 at 5:46




          I revised this answer quite a bit because I learned a lot from egreg's nice answer. Imagine how much I could learn from egreg's question, if he had one. ;-)
          – marmot
          Nov 21 at 5:46




          1




          1




          Wow. Super answer; both very interesting. (I keep discovering, mostly negatively, that commands are redefining things I rely on without my knowledge!) And very helpful. This saves the enterprise just by changing a few characters.
          – Jim Ratliff
          Nov 21 at 5:52




          Wow. Super answer; both very interesting. (I keep discovering, mostly negatively, that commands are redefining things I rely on without my knowledge!) And very helpful. This saves the enterprise just by changing a few characters.
          – Jim Ratliff
          Nov 21 at 5:52




          1




          1




          @JimRatliff Thanks! I actually did not know any of this, so thanks a lot for this really nice question! (How did I get on track? I just added typeouts at many positions of your/Gonzalo's code, which revealed that widest got resetted. Then I did a google search with site:tex.stackexchange.com mathtools setlength, which lead me right to egregs answer. This kind of strategy, i.e. typeouts and google searches with site:tex.stackexchange.com, can sometimes be useful.)
          – marmot
          Nov 21 at 5:59




          @JimRatliff Thanks! I actually did not know any of this, so thanks a lot for this really nice question! (How did I get on track? I just added typeouts at many positions of your/Gonzalo's code, which revealed that widest got resetted. Then I did a google search with site:tex.stackexchange.com mathtools setlength, which lead me right to egregs answer. This kind of strategy, i.e. typeouts and google searches with site:tex.stackexchange.com, can sometimes be useful.)
          – marmot
          Nov 21 at 5:59


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f461056%2fwhy-conflict-between-mathtools-and-gonzalos-solution-for-auto-adjusting-descrip%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

          Quarter-circle Tiles

          build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

          Mont Emei