Hangindent in Custom Environment created with tcolorbox's many Option











up vote
1
down vote

favorite












I wish I could be more specific, but being that I don't understand all of the underlying stuff that's happening, my question will have to be vague (hence the awkward title, I'll edit it to be more specific once I know the details), sorry.



Question: Why does settowidth{hangindent}{some text} not work inside my lemma environment (which is, I think, created using the many option from tcolorbox)?



(I've tried to adjust the parindent, that used to fix some issues with indentation in other tcolorboxes I used, but apparently not here.)



Thanks in advance!



MWE:



documentclass{report}
% Packages used
usepackage[many]{tcolorbox}
% Counter (probably unrelated)
newcounter{lemmacounter}[chapter]
defthelemmacounter{thechapter.arabic{lemmacounter}}

% Where the problem probably lies
% lemma command for lemma environment using tcolorbox (somehow, I'm not really sure how this is working), with optional "name" argument
DeclareDocumentCommand lemma {o} {%
IfNoValueTF {#1} {%
noindentrefstepcounter{lemmacounter}colorbox{black!10}{textbf{L-thelemmacounter}}itshape %
settowidth{hangindent}{L-00 }hangafter=1 % Why does this not work?
}{%
noindentrefstepcounter{lemmacounter}colorbox{black!10}{textbf{L-thelemmacounter}}textbf{ (#1).}itshape
settowidth{hangindent}{L-00 }hangafter=1 % Why does this not work?
}%
}

begin{document}

begin{lemma}[Some Lemma]
Some text some text some text some text some text some text some text some text some text some text some text.
end{lemma}

end{document}


Screenshot of output










share|improve this question


























    up vote
    1
    down vote

    favorite












    I wish I could be more specific, but being that I don't understand all of the underlying stuff that's happening, my question will have to be vague (hence the awkward title, I'll edit it to be more specific once I know the details), sorry.



    Question: Why does settowidth{hangindent}{some text} not work inside my lemma environment (which is, I think, created using the many option from tcolorbox)?



    (I've tried to adjust the parindent, that used to fix some issues with indentation in other tcolorboxes I used, but apparently not here.)



    Thanks in advance!



    MWE:



    documentclass{report}
    % Packages used
    usepackage[many]{tcolorbox}
    % Counter (probably unrelated)
    newcounter{lemmacounter}[chapter]
    defthelemmacounter{thechapter.arabic{lemmacounter}}

    % Where the problem probably lies
    % lemma command for lemma environment using tcolorbox (somehow, I'm not really sure how this is working), with optional "name" argument
    DeclareDocumentCommand lemma {o} {%
    IfNoValueTF {#1} {%
    noindentrefstepcounter{lemmacounter}colorbox{black!10}{textbf{L-thelemmacounter}}itshape %
    settowidth{hangindent}{L-00 }hangafter=1 % Why does this not work?
    }{%
    noindentrefstepcounter{lemmacounter}colorbox{black!10}{textbf{L-thelemmacounter}}textbf{ (#1).}itshape
    settowidth{hangindent}{L-00 }hangafter=1 % Why does this not work?
    }%
    }

    begin{document}

    begin{lemma}[Some Lemma]
    Some text some text some text some text some text some text some text some text some text some text some text.
    end{lemma}

    end{document}


    Screenshot of output










    share|improve this question
























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I wish I could be more specific, but being that I don't understand all of the underlying stuff that's happening, my question will have to be vague (hence the awkward title, I'll edit it to be more specific once I know the details), sorry.



      Question: Why does settowidth{hangindent}{some text} not work inside my lemma environment (which is, I think, created using the many option from tcolorbox)?



      (I've tried to adjust the parindent, that used to fix some issues with indentation in other tcolorboxes I used, but apparently not here.)



      Thanks in advance!



      MWE:



      documentclass{report}
      % Packages used
      usepackage[many]{tcolorbox}
      % Counter (probably unrelated)
      newcounter{lemmacounter}[chapter]
      defthelemmacounter{thechapter.arabic{lemmacounter}}

      % Where the problem probably lies
      % lemma command for lemma environment using tcolorbox (somehow, I'm not really sure how this is working), with optional "name" argument
      DeclareDocumentCommand lemma {o} {%
      IfNoValueTF {#1} {%
      noindentrefstepcounter{lemmacounter}colorbox{black!10}{textbf{L-thelemmacounter}}itshape %
      settowidth{hangindent}{L-00 }hangafter=1 % Why does this not work?
      }{%
      noindentrefstepcounter{lemmacounter}colorbox{black!10}{textbf{L-thelemmacounter}}textbf{ (#1).}itshape
      settowidth{hangindent}{L-00 }hangafter=1 % Why does this not work?
      }%
      }

      begin{document}

      begin{lemma}[Some Lemma]
      Some text some text some text some text some text some text some text some text some text some text some text.
      end{lemma}

      end{document}


      Screenshot of output










      share|improve this question













      I wish I could be more specific, but being that I don't understand all of the underlying stuff that's happening, my question will have to be vague (hence the awkward title, I'll edit it to be more specific once I know the details), sorry.



      Question: Why does settowidth{hangindent}{some text} not work inside my lemma environment (which is, I think, created using the many option from tcolorbox)?



      (I've tried to adjust the parindent, that used to fix some issues with indentation in other tcolorboxes I used, but apparently not here.)



      Thanks in advance!



      MWE:



      documentclass{report}
      % Packages used
      usepackage[many]{tcolorbox}
      % Counter (probably unrelated)
      newcounter{lemmacounter}[chapter]
      defthelemmacounter{thechapter.arabic{lemmacounter}}

      % Where the problem probably lies
      % lemma command for lemma environment using tcolorbox (somehow, I'm not really sure how this is working), with optional "name" argument
      DeclareDocumentCommand lemma {o} {%
      IfNoValueTF {#1} {%
      noindentrefstepcounter{lemmacounter}colorbox{black!10}{textbf{L-thelemmacounter}}itshape %
      settowidth{hangindent}{L-00 }hangafter=1 % Why does this not work?
      }{%
      noindentrefstepcounter{lemmacounter}colorbox{black!10}{textbf{L-thelemmacounter}}textbf{ (#1).}itshape
      settowidth{hangindent}{L-00 }hangafter=1 % Why does this not work?
      }%
      }

      begin{document}

      begin{lemma}[Some Lemma]
      Some text some text some text some text some text some text some text some text some text some text some text.
      end{lemma}

      end{document}


      Screenshot of output







      indentation tcolorbox






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 17 at 4:10









      ABlueChameleon

      335




      335






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          You can achieve your requirement by changing your definitions slightly, here it is:



          newenvironment{lemma}[1][empty]{begingroup
          if!#1!noindentrefstepcounter{lemmacounter}colorbox{black!10}{textbf{L-thelemmacounter}}itshape
          else%
          noindentrefstepcounter{lemmacounter}colorbox{black!10}{textbf{L-thelemmacounter}}textbf{ (#1)}itshapefi
          settowidth{hangindent}{L-00 }hangafter=1%
          }{par%this does the trick for the hangindent
          endgroup}





          share|improve this answer





















          • Thank you very much for your answer, which works nicely; however, could I ask you what the error was in the original code, i.e. why it didn't work? (Also, a small irrelevant edit I can't make, it should be (#1). .)
            – ABlueChameleon
            Nov 17 at 7:04












          • @ABlueChameleon Glad to hear that my advise helps you, and I already mentioned par does the trick, if you give par at the end of the paragraph manually, then your coding also works...
            – MadyYuvi
            Nov 17 at 7:10










          • Oh, I see. I thought that was particular to the new code. Then that's solved too. Thank you!
            – ABlueChameleon
            Nov 17 at 7:24











          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%2f460402%2fhangindent-in-custom-environment-created-with-tcolorboxs-many-option%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
          1
          down vote



          accepted










          You can achieve your requirement by changing your definitions slightly, here it is:



          newenvironment{lemma}[1][empty]{begingroup
          if!#1!noindentrefstepcounter{lemmacounter}colorbox{black!10}{textbf{L-thelemmacounter}}itshape
          else%
          noindentrefstepcounter{lemmacounter}colorbox{black!10}{textbf{L-thelemmacounter}}textbf{ (#1)}itshapefi
          settowidth{hangindent}{L-00 }hangafter=1%
          }{par%this does the trick for the hangindent
          endgroup}





          share|improve this answer





















          • Thank you very much for your answer, which works nicely; however, could I ask you what the error was in the original code, i.e. why it didn't work? (Also, a small irrelevant edit I can't make, it should be (#1). .)
            – ABlueChameleon
            Nov 17 at 7:04












          • @ABlueChameleon Glad to hear that my advise helps you, and I already mentioned par does the trick, if you give par at the end of the paragraph manually, then your coding also works...
            – MadyYuvi
            Nov 17 at 7:10










          • Oh, I see. I thought that was particular to the new code. Then that's solved too. Thank you!
            – ABlueChameleon
            Nov 17 at 7:24















          up vote
          1
          down vote



          accepted










          You can achieve your requirement by changing your definitions slightly, here it is:



          newenvironment{lemma}[1][empty]{begingroup
          if!#1!noindentrefstepcounter{lemmacounter}colorbox{black!10}{textbf{L-thelemmacounter}}itshape
          else%
          noindentrefstepcounter{lemmacounter}colorbox{black!10}{textbf{L-thelemmacounter}}textbf{ (#1)}itshapefi
          settowidth{hangindent}{L-00 }hangafter=1%
          }{par%this does the trick for the hangindent
          endgroup}





          share|improve this answer





















          • Thank you very much for your answer, which works nicely; however, could I ask you what the error was in the original code, i.e. why it didn't work? (Also, a small irrelevant edit I can't make, it should be (#1). .)
            – ABlueChameleon
            Nov 17 at 7:04












          • @ABlueChameleon Glad to hear that my advise helps you, and I already mentioned par does the trick, if you give par at the end of the paragraph manually, then your coding also works...
            – MadyYuvi
            Nov 17 at 7:10










          • Oh, I see. I thought that was particular to the new code. Then that's solved too. Thank you!
            – ABlueChameleon
            Nov 17 at 7:24













          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted






          You can achieve your requirement by changing your definitions slightly, here it is:



          newenvironment{lemma}[1][empty]{begingroup
          if!#1!noindentrefstepcounter{lemmacounter}colorbox{black!10}{textbf{L-thelemmacounter}}itshape
          else%
          noindentrefstepcounter{lemmacounter}colorbox{black!10}{textbf{L-thelemmacounter}}textbf{ (#1)}itshapefi
          settowidth{hangindent}{L-00 }hangafter=1%
          }{par%this does the trick for the hangindent
          endgroup}





          share|improve this answer












          You can achieve your requirement by changing your definitions slightly, here it is:



          newenvironment{lemma}[1][empty]{begingroup
          if!#1!noindentrefstepcounter{lemmacounter}colorbox{black!10}{textbf{L-thelemmacounter}}itshape
          else%
          noindentrefstepcounter{lemmacounter}colorbox{black!10}{textbf{L-thelemmacounter}}textbf{ (#1)}itshapefi
          settowidth{hangindent}{L-00 }hangafter=1%
          }{par%this does the trick for the hangindent
          endgroup}






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 17 at 6:58









          MadyYuvi

          1,984211




          1,984211












          • Thank you very much for your answer, which works nicely; however, could I ask you what the error was in the original code, i.e. why it didn't work? (Also, a small irrelevant edit I can't make, it should be (#1). .)
            – ABlueChameleon
            Nov 17 at 7:04












          • @ABlueChameleon Glad to hear that my advise helps you, and I already mentioned par does the trick, if you give par at the end of the paragraph manually, then your coding also works...
            – MadyYuvi
            Nov 17 at 7:10










          • Oh, I see. I thought that was particular to the new code. Then that's solved too. Thank you!
            – ABlueChameleon
            Nov 17 at 7:24


















          • Thank you very much for your answer, which works nicely; however, could I ask you what the error was in the original code, i.e. why it didn't work? (Also, a small irrelevant edit I can't make, it should be (#1). .)
            – ABlueChameleon
            Nov 17 at 7:04












          • @ABlueChameleon Glad to hear that my advise helps you, and I already mentioned par does the trick, if you give par at the end of the paragraph manually, then your coding also works...
            – MadyYuvi
            Nov 17 at 7:10










          • Oh, I see. I thought that was particular to the new code. Then that's solved too. Thank you!
            – ABlueChameleon
            Nov 17 at 7:24
















          Thank you very much for your answer, which works nicely; however, could I ask you what the error was in the original code, i.e. why it didn't work? (Also, a small irrelevant edit I can't make, it should be (#1). .)
          – ABlueChameleon
          Nov 17 at 7:04






          Thank you very much for your answer, which works nicely; however, could I ask you what the error was in the original code, i.e. why it didn't work? (Also, a small irrelevant edit I can't make, it should be (#1). .)
          – ABlueChameleon
          Nov 17 at 7:04














          @ABlueChameleon Glad to hear that my advise helps you, and I already mentioned par does the trick, if you give par at the end of the paragraph manually, then your coding also works...
          – MadyYuvi
          Nov 17 at 7:10




          @ABlueChameleon Glad to hear that my advise helps you, and I already mentioned par does the trick, if you give par at the end of the paragraph manually, then your coding also works...
          – MadyYuvi
          Nov 17 at 7:10












          Oh, I see. I thought that was particular to the new code. Then that's solved too. Thank you!
          – ABlueChameleon
          Nov 17 at 7:24




          Oh, I see. I thought that was particular to the new code. Then that's solved too. Thank you!
          – ABlueChameleon
          Nov 17 at 7:24


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f460402%2fhangindent-in-custom-environment-created-with-tcolorboxs-many-option%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

          How to change which sound is reproduced for terminal bell?

          Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

          Can I use Tabulator js library in my java Spring + Thymeleaf project?