How to do calculations with a LaTeX counter in a newtcolorbox environment?












5















I created a course summary box. In order to distinguish the summaries by school year, I have put an optional argument that displays the latter in the upper left corner (highlighted in yellow on the screenshot).



enter image description here



To display this school year, I write a fraction in the optional argument, like this:



begin{resume}[$sfrac{2018}{2019}$]{chapitre 1}
tcbsubtitle{Définition}

lipsum[1]
end{resume}


In order to simplify the code and also to progress in LaTeX, I want to modify this argument to transmit only the year 2018, then automatically calculate the next school year and display the fraction 2018/2019.



To do this, I created a counter called annee,



%setcounter{annee}{#1}


but when I try to use it in a tcolorbox, I have this error:




! Missing endcsname
inserted.




documentclass{article}
usepackage{lipsum}
usepackage{xfrac}
usepackage[most]{tcolorbox}

newcounter{annee}

tcbset{titreresume/.style={boxed title style={colframe=black!15,colbacktitle=gray!75,
leftrule=1.5mm,rightrule=1.5mm,toprule=1.5pt,bottom=0pt,boxsep=1pt}}}

tcbset{soustitre/.style={subtitle style={colback=black!7,colframe=black!25,
boxsep=1mm,fontupper={sffamilybfserieslargeselectfontcolor{black!63}}}}}

newtcolorbox[auto counter]{resume}[2]{%
%setcounter{annee}{#1}
minipage boxed title*=-106mm,
before upper={textcolor{black!63}{#1 hfill #2hfillthetcbcounter/pageref{nombre-de-page}}},
titreresume,soustitre,colframe=black!25,colback=white,leftrule=3mm,rightrule=3mm,toprule=2pt,bottomrule=2pt,left=3pt,right=0pt,top=3mm,
fonttitle=sffamilybfserieslarge,label={nombre-de-page},
enhanced,nobeforeafter,lower separated=false,attach boxed title to top center={yshift=-3mm,xshift=-linewidth/5},
title={normalsize Résumé}}

begin{document}

begin{resume}[$sfrac{2018}{2019}$]{chapitre 1}
tcbsubtitle{Définition}

lipsum[1]
end{resume}

newpage

begin{resume}[$sfrac{2018}{2019}$]{chapitre 1}

tcbsubtitle{Propriétés}
lipsum[2]
end{resume}
end{document}


How do I do calculations with a LaTeX counter in a tcolorbox?



Translated with www.DeepL.com/Translator










share|improve this question





























    5















    I created a course summary box. In order to distinguish the summaries by school year, I have put an optional argument that displays the latter in the upper left corner (highlighted in yellow on the screenshot).



    enter image description here



    To display this school year, I write a fraction in the optional argument, like this:



    begin{resume}[$sfrac{2018}{2019}$]{chapitre 1}
    tcbsubtitle{Définition}

    lipsum[1]
    end{resume}


    In order to simplify the code and also to progress in LaTeX, I want to modify this argument to transmit only the year 2018, then automatically calculate the next school year and display the fraction 2018/2019.



    To do this, I created a counter called annee,



    %setcounter{annee}{#1}


    but when I try to use it in a tcolorbox, I have this error:




    ! Missing endcsname
    inserted.




    documentclass{article}
    usepackage{lipsum}
    usepackage{xfrac}
    usepackage[most]{tcolorbox}

    newcounter{annee}

    tcbset{titreresume/.style={boxed title style={colframe=black!15,colbacktitle=gray!75,
    leftrule=1.5mm,rightrule=1.5mm,toprule=1.5pt,bottom=0pt,boxsep=1pt}}}

    tcbset{soustitre/.style={subtitle style={colback=black!7,colframe=black!25,
    boxsep=1mm,fontupper={sffamilybfserieslargeselectfontcolor{black!63}}}}}

    newtcolorbox[auto counter]{resume}[2]{%
    %setcounter{annee}{#1}
    minipage boxed title*=-106mm,
    before upper={textcolor{black!63}{#1 hfill #2hfillthetcbcounter/pageref{nombre-de-page}}},
    titreresume,soustitre,colframe=black!25,colback=white,leftrule=3mm,rightrule=3mm,toprule=2pt,bottomrule=2pt,left=3pt,right=0pt,top=3mm,
    fonttitle=sffamilybfserieslarge,label={nombre-de-page},
    enhanced,nobeforeafter,lower separated=false,attach boxed title to top center={yshift=-3mm,xshift=-linewidth/5},
    title={normalsize Résumé}}

    begin{document}

    begin{resume}[$sfrac{2018}{2019}$]{chapitre 1}
    tcbsubtitle{Définition}

    lipsum[1]
    end{resume}

    newpage

    begin{resume}[$sfrac{2018}{2019}$]{chapitre 1}

    tcbsubtitle{Propriétés}
    lipsum[2]
    end{resume}
    end{document}


    How do I do calculations with a LaTeX counter in a tcolorbox?



    Translated with www.DeepL.com/Translator










    share|improve this question



























      5












      5








      5








      I created a course summary box. In order to distinguish the summaries by school year, I have put an optional argument that displays the latter in the upper left corner (highlighted in yellow on the screenshot).



      enter image description here



      To display this school year, I write a fraction in the optional argument, like this:



      begin{resume}[$sfrac{2018}{2019}$]{chapitre 1}
      tcbsubtitle{Définition}

      lipsum[1]
      end{resume}


      In order to simplify the code and also to progress in LaTeX, I want to modify this argument to transmit only the year 2018, then automatically calculate the next school year and display the fraction 2018/2019.



      To do this, I created a counter called annee,



      %setcounter{annee}{#1}


      but when I try to use it in a tcolorbox, I have this error:




      ! Missing endcsname
      inserted.




      documentclass{article}
      usepackage{lipsum}
      usepackage{xfrac}
      usepackage[most]{tcolorbox}

      newcounter{annee}

      tcbset{titreresume/.style={boxed title style={colframe=black!15,colbacktitle=gray!75,
      leftrule=1.5mm,rightrule=1.5mm,toprule=1.5pt,bottom=0pt,boxsep=1pt}}}

      tcbset{soustitre/.style={subtitle style={colback=black!7,colframe=black!25,
      boxsep=1mm,fontupper={sffamilybfserieslargeselectfontcolor{black!63}}}}}

      newtcolorbox[auto counter]{resume}[2]{%
      %setcounter{annee}{#1}
      minipage boxed title*=-106mm,
      before upper={textcolor{black!63}{#1 hfill #2hfillthetcbcounter/pageref{nombre-de-page}}},
      titreresume,soustitre,colframe=black!25,colback=white,leftrule=3mm,rightrule=3mm,toprule=2pt,bottomrule=2pt,left=3pt,right=0pt,top=3mm,
      fonttitle=sffamilybfserieslarge,label={nombre-de-page},
      enhanced,nobeforeafter,lower separated=false,attach boxed title to top center={yshift=-3mm,xshift=-linewidth/5},
      title={normalsize Résumé}}

      begin{document}

      begin{resume}[$sfrac{2018}{2019}$]{chapitre 1}
      tcbsubtitle{Définition}

      lipsum[1]
      end{resume}

      newpage

      begin{resume}[$sfrac{2018}{2019}$]{chapitre 1}

      tcbsubtitle{Propriétés}
      lipsum[2]
      end{resume}
      end{document}


      How do I do calculations with a LaTeX counter in a tcolorbox?



      Translated with www.DeepL.com/Translator










      share|improve this question
















      I created a course summary box. In order to distinguish the summaries by school year, I have put an optional argument that displays the latter in the upper left corner (highlighted in yellow on the screenshot).



      enter image description here



      To display this school year, I write a fraction in the optional argument, like this:



      begin{resume}[$sfrac{2018}{2019}$]{chapitre 1}
      tcbsubtitle{Définition}

      lipsum[1]
      end{resume}


      In order to simplify the code and also to progress in LaTeX, I want to modify this argument to transmit only the year 2018, then automatically calculate the next school year and display the fraction 2018/2019.



      To do this, I created a counter called annee,



      %setcounter{annee}{#1}


      but when I try to use it in a tcolorbox, I have this error:




      ! Missing endcsname
      inserted.




      documentclass{article}
      usepackage{lipsum}
      usepackage{xfrac}
      usepackage[most]{tcolorbox}

      newcounter{annee}

      tcbset{titreresume/.style={boxed title style={colframe=black!15,colbacktitle=gray!75,
      leftrule=1.5mm,rightrule=1.5mm,toprule=1.5pt,bottom=0pt,boxsep=1pt}}}

      tcbset{soustitre/.style={subtitle style={colback=black!7,colframe=black!25,
      boxsep=1mm,fontupper={sffamilybfserieslargeselectfontcolor{black!63}}}}}

      newtcolorbox[auto counter]{resume}[2]{%
      %setcounter{annee}{#1}
      minipage boxed title*=-106mm,
      before upper={textcolor{black!63}{#1 hfill #2hfillthetcbcounter/pageref{nombre-de-page}}},
      titreresume,soustitre,colframe=black!25,colback=white,leftrule=3mm,rightrule=3mm,toprule=2pt,bottomrule=2pt,left=3pt,right=0pt,top=3mm,
      fonttitle=sffamilybfserieslarge,label={nombre-de-page},
      enhanced,nobeforeafter,lower separated=false,attach boxed title to top center={yshift=-3mm,xshift=-linewidth/5},
      title={normalsize Résumé}}

      begin{document}

      begin{resume}[$sfrac{2018}{2019}$]{chapitre 1}
      tcbsubtitle{Définition}

      lipsum[1]
      end{resume}

      newpage

      begin{resume}[$sfrac{2018}{2019}$]{chapitre 1}

      tcbsubtitle{Propriétés}
      lipsum[2]
      end{resume}
      end{document}


      How do I do calculations with a LaTeX counter in a tcolorbox?



      Translated with www.DeepL.com/Translator







      tcolorbox counters calculations






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 24 '18 at 15:27







      AndréC

















      asked Dec 24 '18 at 15:17









      AndréCAndréC

      10.1k11547




      10.1k11547






















          2 Answers
          2






          active

          oldest

          votes


















          11














          Well you can't set the counter in the middle of a key-val-list. But beside this you don't need a counter for this:



          documentclass{article}
          usepackage{lipsum}
          usepackage{xfrac}
          usepackage[most]{tcolorbox}


          tcbset{titreresume/.style={boxed title style={colframe=black!15,colbacktitle=gray!75,
          leftrule=1.5mm,rightrule=1.5mm,toprule=1.5pt,bottom=0pt,boxsep=1pt}}}

          tcbset{soustitre/.style={subtitle style={colback=black!7,colframe=black!25,
          boxsep=1mm,fontupper={sffamilybfserieslargeselectfontcolor{black!63}}}}}

          newtcolorbox[auto counter]{resume}[2][0]{%
          minipage boxed title*=-106mm,
          before upper={textcolor{black!63}{sfrac{#1}{thenumexpr#1+1} hfill #2hfillthetcbcounter/pageref{nombre-de-page}}},
          titreresume,soustitre,colframe=black!25,colback=white,leftrule=3mm,rightrule=3mm,toprule=2pt,bottomrule=2pt,left=3pt,right=0pt,top=3mm,
          fonttitle=sffamilybfserieslarge,label={nombre-de-page},
          enhanced,nobeforeafter,lower separated=false,attach boxed title to top center={yshift=-3mm,xshift=-linewidth/5},
          title={normalsize Résumé}}

          begin{document}

          begin{resume}[2018]{chapitre 1}
          tcbsubtitle{Définition}

          lipsum[1]
          end{resume}

          newpage

          begin{resume}[2018]{chapitre 1}

          tcbsubtitle{Propriétés}
          lipsum[2]
          end{resume}
          end{document}


          enter image description here






          share|improve this answer
























          • What is thenumexpr? A TeX register? Or something else?

            – AndréC
            Dec 24 '18 at 15:35








          • 2





            tex.stackexchange.com/a/88346/2388

            – Ulrike Fischer
            Dec 24 '18 at 15:48











          • Why is it allowed to use numexpr which is an e-TeX registry and not a LaTeX newcounter when both are registries (if I'm not mistaken)?

            – AndréC
            Dec 25 '18 at 7:21






          • 2





            @AndréC: newcounter{foo} involves the definition of c@foo, a TeX counter register, but macro definition isn't expandable; direct usage of numexpr is expandable...

            – Christian Hupfer
            Dec 25 '18 at 10:33








          • 1





            @AndréC: I don't know of such list, but that doesn't mean there is none!

            – Christian Hupfer
            Dec 25 '18 at 22:15





















          10














          Similar to Ulrike's answer, but using the TeX counter year by default or adding an optional argument for other years.



          I switched also to the NewTColorBox way, providing better argument control, i.e. using #1 as the usual 1st argument for options.



          Of course, there is the caveat, that by recompilation of the file in another year than supposed (i.e. 2018/2019 will be recompiled in, say, 2020/2021) the theyear approach will change the 'time stamp'



          documentclass{article}
          usepackage{lipsum}
          usepackage{xfrac}
          usepackage[most]{tcolorbox}

          newcounter{annee}

          tcbset{titreresume/.style={boxed title style={colframe=black!15,colbacktitle=gray!75,
          leftrule=1.5mm,rightrule=1.5mm,toprule=1.5pt,bottom=0pt,boxsep=1pt}}}

          tcbset{soustitre/.style={subtitle style={colback=black!7,colframe=black!25,
          boxsep=1mm,fontupper={sffamilybfserieslargeselectfontcolor{black!63}}}}}

          NewTColorBox[auto counter]{resume}{+O{}+m+O{theyear}}{%
          %setcounter{annee}{#1}
          minipage boxed title*=-106mm,
          before upper={textcolor{black!63}{sfrac{#3}{thenumexpr#3+1} hfill #2hfillthetcbcounter/pageref{nombre-de-page}}},
          titreresume,soustitre,colframe=black!25,colback=white,leftrule=3mm,rightrule=3mm,toprule=2pt,bottomrule=2pt,left=3pt,right=0pt,top=3mm,
          fonttitle=sffamilybfserieslarge,label={nombre-de-page},
          enhanced,nobeforeafter,lower separated=false,attach boxed title to top center={yshift=-3mm,xshift=-linewidth/5},
          title={normalsize Résumé},#1}

          begin{document}

          begin{resume}{chapitre 1}[2017]
          tcbsubtitle{Définition}

          lipsum[1]
          end{resume}

          clearpage
          begin{resume}{chapitre 1}

          tcbsubtitle{Propriétés}
          lipsum[2]
          end{resume}
          end{document}


          enter image description here






          share|improve this answer


























          • The page number at the top right is no longer displayed instead of 1/2 it only appears /2

            – AndréC
            Dec 24 '18 at 16:23






          • 2





            @AndréC: I deleted the [auto counter] feature, I reinstalled it and it works again. you are getting into troubles anyway by using the same label more than once...

            – Christian Hupfer
            Dec 24 '18 at 16:27








          • 4





            +1 just for seeing an answer by you. Frohe Weihnachten!

            – marmot
            Dec 24 '18 at 16:28











          • Indeed, I do not know why this warning appears or how to correct it. LaTeX LaTeX Warning: Label "nombre-de-page" multiply defined. Nevertheless, it works very well with this warning.

            – AndréC
            Dec 24 '18 at 16:33








          • 1





            @AndréC: just in case you have floats on the page etc or the tcolorbox itself is floating, you most likely want to have shipped it out before the next page starts.

            – Christian Hupfer
            Dec 25 '18 at 7:04











          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%2f467192%2fhow-to-do-calculations-with-a-latex-counter-in-a-newtcolorbox-environment%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









          11














          Well you can't set the counter in the middle of a key-val-list. But beside this you don't need a counter for this:



          documentclass{article}
          usepackage{lipsum}
          usepackage{xfrac}
          usepackage[most]{tcolorbox}


          tcbset{titreresume/.style={boxed title style={colframe=black!15,colbacktitle=gray!75,
          leftrule=1.5mm,rightrule=1.5mm,toprule=1.5pt,bottom=0pt,boxsep=1pt}}}

          tcbset{soustitre/.style={subtitle style={colback=black!7,colframe=black!25,
          boxsep=1mm,fontupper={sffamilybfserieslargeselectfontcolor{black!63}}}}}

          newtcolorbox[auto counter]{resume}[2][0]{%
          minipage boxed title*=-106mm,
          before upper={textcolor{black!63}{sfrac{#1}{thenumexpr#1+1} hfill #2hfillthetcbcounter/pageref{nombre-de-page}}},
          titreresume,soustitre,colframe=black!25,colback=white,leftrule=3mm,rightrule=3mm,toprule=2pt,bottomrule=2pt,left=3pt,right=0pt,top=3mm,
          fonttitle=sffamilybfserieslarge,label={nombre-de-page},
          enhanced,nobeforeafter,lower separated=false,attach boxed title to top center={yshift=-3mm,xshift=-linewidth/5},
          title={normalsize Résumé}}

          begin{document}

          begin{resume}[2018]{chapitre 1}
          tcbsubtitle{Définition}

          lipsum[1]
          end{resume}

          newpage

          begin{resume}[2018]{chapitre 1}

          tcbsubtitle{Propriétés}
          lipsum[2]
          end{resume}
          end{document}


          enter image description here






          share|improve this answer
























          • What is thenumexpr? A TeX register? Or something else?

            – AndréC
            Dec 24 '18 at 15:35








          • 2





            tex.stackexchange.com/a/88346/2388

            – Ulrike Fischer
            Dec 24 '18 at 15:48











          • Why is it allowed to use numexpr which is an e-TeX registry and not a LaTeX newcounter when both are registries (if I'm not mistaken)?

            – AndréC
            Dec 25 '18 at 7:21






          • 2





            @AndréC: newcounter{foo} involves the definition of c@foo, a TeX counter register, but macro definition isn't expandable; direct usage of numexpr is expandable...

            – Christian Hupfer
            Dec 25 '18 at 10:33








          • 1





            @AndréC: I don't know of such list, but that doesn't mean there is none!

            – Christian Hupfer
            Dec 25 '18 at 22:15


















          11














          Well you can't set the counter in the middle of a key-val-list. But beside this you don't need a counter for this:



          documentclass{article}
          usepackage{lipsum}
          usepackage{xfrac}
          usepackage[most]{tcolorbox}


          tcbset{titreresume/.style={boxed title style={colframe=black!15,colbacktitle=gray!75,
          leftrule=1.5mm,rightrule=1.5mm,toprule=1.5pt,bottom=0pt,boxsep=1pt}}}

          tcbset{soustitre/.style={subtitle style={colback=black!7,colframe=black!25,
          boxsep=1mm,fontupper={sffamilybfserieslargeselectfontcolor{black!63}}}}}

          newtcolorbox[auto counter]{resume}[2][0]{%
          minipage boxed title*=-106mm,
          before upper={textcolor{black!63}{sfrac{#1}{thenumexpr#1+1} hfill #2hfillthetcbcounter/pageref{nombre-de-page}}},
          titreresume,soustitre,colframe=black!25,colback=white,leftrule=3mm,rightrule=3mm,toprule=2pt,bottomrule=2pt,left=3pt,right=0pt,top=3mm,
          fonttitle=sffamilybfserieslarge,label={nombre-de-page},
          enhanced,nobeforeafter,lower separated=false,attach boxed title to top center={yshift=-3mm,xshift=-linewidth/5},
          title={normalsize Résumé}}

          begin{document}

          begin{resume}[2018]{chapitre 1}
          tcbsubtitle{Définition}

          lipsum[1]
          end{resume}

          newpage

          begin{resume}[2018]{chapitre 1}

          tcbsubtitle{Propriétés}
          lipsum[2]
          end{resume}
          end{document}


          enter image description here






          share|improve this answer
























          • What is thenumexpr? A TeX register? Or something else?

            – AndréC
            Dec 24 '18 at 15:35








          • 2





            tex.stackexchange.com/a/88346/2388

            – Ulrike Fischer
            Dec 24 '18 at 15:48











          • Why is it allowed to use numexpr which is an e-TeX registry and not a LaTeX newcounter when both are registries (if I'm not mistaken)?

            – AndréC
            Dec 25 '18 at 7:21






          • 2





            @AndréC: newcounter{foo} involves the definition of c@foo, a TeX counter register, but macro definition isn't expandable; direct usage of numexpr is expandable...

            – Christian Hupfer
            Dec 25 '18 at 10:33








          • 1





            @AndréC: I don't know of such list, but that doesn't mean there is none!

            – Christian Hupfer
            Dec 25 '18 at 22:15
















          11












          11








          11







          Well you can't set the counter in the middle of a key-val-list. But beside this you don't need a counter for this:



          documentclass{article}
          usepackage{lipsum}
          usepackage{xfrac}
          usepackage[most]{tcolorbox}


          tcbset{titreresume/.style={boxed title style={colframe=black!15,colbacktitle=gray!75,
          leftrule=1.5mm,rightrule=1.5mm,toprule=1.5pt,bottom=0pt,boxsep=1pt}}}

          tcbset{soustitre/.style={subtitle style={colback=black!7,colframe=black!25,
          boxsep=1mm,fontupper={sffamilybfserieslargeselectfontcolor{black!63}}}}}

          newtcolorbox[auto counter]{resume}[2][0]{%
          minipage boxed title*=-106mm,
          before upper={textcolor{black!63}{sfrac{#1}{thenumexpr#1+1} hfill #2hfillthetcbcounter/pageref{nombre-de-page}}},
          titreresume,soustitre,colframe=black!25,colback=white,leftrule=3mm,rightrule=3mm,toprule=2pt,bottomrule=2pt,left=3pt,right=0pt,top=3mm,
          fonttitle=sffamilybfserieslarge,label={nombre-de-page},
          enhanced,nobeforeafter,lower separated=false,attach boxed title to top center={yshift=-3mm,xshift=-linewidth/5},
          title={normalsize Résumé}}

          begin{document}

          begin{resume}[2018]{chapitre 1}
          tcbsubtitle{Définition}

          lipsum[1]
          end{resume}

          newpage

          begin{resume}[2018]{chapitre 1}

          tcbsubtitle{Propriétés}
          lipsum[2]
          end{resume}
          end{document}


          enter image description here






          share|improve this answer













          Well you can't set the counter in the middle of a key-val-list. But beside this you don't need a counter for this:



          documentclass{article}
          usepackage{lipsum}
          usepackage{xfrac}
          usepackage[most]{tcolorbox}


          tcbset{titreresume/.style={boxed title style={colframe=black!15,colbacktitle=gray!75,
          leftrule=1.5mm,rightrule=1.5mm,toprule=1.5pt,bottom=0pt,boxsep=1pt}}}

          tcbset{soustitre/.style={subtitle style={colback=black!7,colframe=black!25,
          boxsep=1mm,fontupper={sffamilybfserieslargeselectfontcolor{black!63}}}}}

          newtcolorbox[auto counter]{resume}[2][0]{%
          minipage boxed title*=-106mm,
          before upper={textcolor{black!63}{sfrac{#1}{thenumexpr#1+1} hfill #2hfillthetcbcounter/pageref{nombre-de-page}}},
          titreresume,soustitre,colframe=black!25,colback=white,leftrule=3mm,rightrule=3mm,toprule=2pt,bottomrule=2pt,left=3pt,right=0pt,top=3mm,
          fonttitle=sffamilybfserieslarge,label={nombre-de-page},
          enhanced,nobeforeafter,lower separated=false,attach boxed title to top center={yshift=-3mm,xshift=-linewidth/5},
          title={normalsize Résumé}}

          begin{document}

          begin{resume}[2018]{chapitre 1}
          tcbsubtitle{Définition}

          lipsum[1]
          end{resume}

          newpage

          begin{resume}[2018]{chapitre 1}

          tcbsubtitle{Propriétés}
          lipsum[2]
          end{resume}
          end{document}


          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 24 '18 at 15:25









          Ulrike FischerUlrike Fischer

          194k8302688




          194k8302688













          • What is thenumexpr? A TeX register? Or something else?

            – AndréC
            Dec 24 '18 at 15:35








          • 2





            tex.stackexchange.com/a/88346/2388

            – Ulrike Fischer
            Dec 24 '18 at 15:48











          • Why is it allowed to use numexpr which is an e-TeX registry and not a LaTeX newcounter when both are registries (if I'm not mistaken)?

            – AndréC
            Dec 25 '18 at 7:21






          • 2





            @AndréC: newcounter{foo} involves the definition of c@foo, a TeX counter register, but macro definition isn't expandable; direct usage of numexpr is expandable...

            – Christian Hupfer
            Dec 25 '18 at 10:33








          • 1





            @AndréC: I don't know of such list, but that doesn't mean there is none!

            – Christian Hupfer
            Dec 25 '18 at 22:15





















          • What is thenumexpr? A TeX register? Or something else?

            – AndréC
            Dec 24 '18 at 15:35








          • 2





            tex.stackexchange.com/a/88346/2388

            – Ulrike Fischer
            Dec 24 '18 at 15:48











          • Why is it allowed to use numexpr which is an e-TeX registry and not a LaTeX newcounter when both are registries (if I'm not mistaken)?

            – AndréC
            Dec 25 '18 at 7:21






          • 2





            @AndréC: newcounter{foo} involves the definition of c@foo, a TeX counter register, but macro definition isn't expandable; direct usage of numexpr is expandable...

            – Christian Hupfer
            Dec 25 '18 at 10:33








          • 1





            @AndréC: I don't know of such list, but that doesn't mean there is none!

            – Christian Hupfer
            Dec 25 '18 at 22:15



















          What is thenumexpr? A TeX register? Or something else?

          – AndréC
          Dec 24 '18 at 15:35







          What is thenumexpr? A TeX register? Or something else?

          – AndréC
          Dec 24 '18 at 15:35






          2




          2





          tex.stackexchange.com/a/88346/2388

          – Ulrike Fischer
          Dec 24 '18 at 15:48





          tex.stackexchange.com/a/88346/2388

          – Ulrike Fischer
          Dec 24 '18 at 15:48













          Why is it allowed to use numexpr which is an e-TeX registry and not a LaTeX newcounter when both are registries (if I'm not mistaken)?

          – AndréC
          Dec 25 '18 at 7:21





          Why is it allowed to use numexpr which is an e-TeX registry and not a LaTeX newcounter when both are registries (if I'm not mistaken)?

          – AndréC
          Dec 25 '18 at 7:21




          2




          2





          @AndréC: newcounter{foo} involves the definition of c@foo, a TeX counter register, but macro definition isn't expandable; direct usage of numexpr is expandable...

          – Christian Hupfer
          Dec 25 '18 at 10:33







          @AndréC: newcounter{foo} involves the definition of c@foo, a TeX counter register, but macro definition isn't expandable; direct usage of numexpr is expandable...

          – Christian Hupfer
          Dec 25 '18 at 10:33






          1




          1





          @AndréC: I don't know of such list, but that doesn't mean there is none!

          – Christian Hupfer
          Dec 25 '18 at 22:15







          @AndréC: I don't know of such list, but that doesn't mean there is none!

          – Christian Hupfer
          Dec 25 '18 at 22:15













          10














          Similar to Ulrike's answer, but using the TeX counter year by default or adding an optional argument for other years.



          I switched also to the NewTColorBox way, providing better argument control, i.e. using #1 as the usual 1st argument for options.



          Of course, there is the caveat, that by recompilation of the file in another year than supposed (i.e. 2018/2019 will be recompiled in, say, 2020/2021) the theyear approach will change the 'time stamp'



          documentclass{article}
          usepackage{lipsum}
          usepackage{xfrac}
          usepackage[most]{tcolorbox}

          newcounter{annee}

          tcbset{titreresume/.style={boxed title style={colframe=black!15,colbacktitle=gray!75,
          leftrule=1.5mm,rightrule=1.5mm,toprule=1.5pt,bottom=0pt,boxsep=1pt}}}

          tcbset{soustitre/.style={subtitle style={colback=black!7,colframe=black!25,
          boxsep=1mm,fontupper={sffamilybfserieslargeselectfontcolor{black!63}}}}}

          NewTColorBox[auto counter]{resume}{+O{}+m+O{theyear}}{%
          %setcounter{annee}{#1}
          minipage boxed title*=-106mm,
          before upper={textcolor{black!63}{sfrac{#3}{thenumexpr#3+1} hfill #2hfillthetcbcounter/pageref{nombre-de-page}}},
          titreresume,soustitre,colframe=black!25,colback=white,leftrule=3mm,rightrule=3mm,toprule=2pt,bottomrule=2pt,left=3pt,right=0pt,top=3mm,
          fonttitle=sffamilybfserieslarge,label={nombre-de-page},
          enhanced,nobeforeafter,lower separated=false,attach boxed title to top center={yshift=-3mm,xshift=-linewidth/5},
          title={normalsize Résumé},#1}

          begin{document}

          begin{resume}{chapitre 1}[2017]
          tcbsubtitle{Définition}

          lipsum[1]
          end{resume}

          clearpage
          begin{resume}{chapitre 1}

          tcbsubtitle{Propriétés}
          lipsum[2]
          end{resume}
          end{document}


          enter image description here






          share|improve this answer


























          • The page number at the top right is no longer displayed instead of 1/2 it only appears /2

            – AndréC
            Dec 24 '18 at 16:23






          • 2





            @AndréC: I deleted the [auto counter] feature, I reinstalled it and it works again. you are getting into troubles anyway by using the same label more than once...

            – Christian Hupfer
            Dec 24 '18 at 16:27








          • 4





            +1 just for seeing an answer by you. Frohe Weihnachten!

            – marmot
            Dec 24 '18 at 16:28











          • Indeed, I do not know why this warning appears or how to correct it. LaTeX LaTeX Warning: Label "nombre-de-page" multiply defined. Nevertheless, it works very well with this warning.

            – AndréC
            Dec 24 '18 at 16:33








          • 1





            @AndréC: just in case you have floats on the page etc or the tcolorbox itself is floating, you most likely want to have shipped it out before the next page starts.

            – Christian Hupfer
            Dec 25 '18 at 7:04
















          10














          Similar to Ulrike's answer, but using the TeX counter year by default or adding an optional argument for other years.



          I switched also to the NewTColorBox way, providing better argument control, i.e. using #1 as the usual 1st argument for options.



          Of course, there is the caveat, that by recompilation of the file in another year than supposed (i.e. 2018/2019 will be recompiled in, say, 2020/2021) the theyear approach will change the 'time stamp'



          documentclass{article}
          usepackage{lipsum}
          usepackage{xfrac}
          usepackage[most]{tcolorbox}

          newcounter{annee}

          tcbset{titreresume/.style={boxed title style={colframe=black!15,colbacktitle=gray!75,
          leftrule=1.5mm,rightrule=1.5mm,toprule=1.5pt,bottom=0pt,boxsep=1pt}}}

          tcbset{soustitre/.style={subtitle style={colback=black!7,colframe=black!25,
          boxsep=1mm,fontupper={sffamilybfserieslargeselectfontcolor{black!63}}}}}

          NewTColorBox[auto counter]{resume}{+O{}+m+O{theyear}}{%
          %setcounter{annee}{#1}
          minipage boxed title*=-106mm,
          before upper={textcolor{black!63}{sfrac{#3}{thenumexpr#3+1} hfill #2hfillthetcbcounter/pageref{nombre-de-page}}},
          titreresume,soustitre,colframe=black!25,colback=white,leftrule=3mm,rightrule=3mm,toprule=2pt,bottomrule=2pt,left=3pt,right=0pt,top=3mm,
          fonttitle=sffamilybfserieslarge,label={nombre-de-page},
          enhanced,nobeforeafter,lower separated=false,attach boxed title to top center={yshift=-3mm,xshift=-linewidth/5},
          title={normalsize Résumé},#1}

          begin{document}

          begin{resume}{chapitre 1}[2017]
          tcbsubtitle{Définition}

          lipsum[1]
          end{resume}

          clearpage
          begin{resume}{chapitre 1}

          tcbsubtitle{Propriétés}
          lipsum[2]
          end{resume}
          end{document}


          enter image description here






          share|improve this answer


























          • The page number at the top right is no longer displayed instead of 1/2 it only appears /2

            – AndréC
            Dec 24 '18 at 16:23






          • 2





            @AndréC: I deleted the [auto counter] feature, I reinstalled it and it works again. you are getting into troubles anyway by using the same label more than once...

            – Christian Hupfer
            Dec 24 '18 at 16:27








          • 4





            +1 just for seeing an answer by you. Frohe Weihnachten!

            – marmot
            Dec 24 '18 at 16:28











          • Indeed, I do not know why this warning appears or how to correct it. LaTeX LaTeX Warning: Label "nombre-de-page" multiply defined. Nevertheless, it works very well with this warning.

            – AndréC
            Dec 24 '18 at 16:33








          • 1





            @AndréC: just in case you have floats on the page etc or the tcolorbox itself is floating, you most likely want to have shipped it out before the next page starts.

            – Christian Hupfer
            Dec 25 '18 at 7:04














          10












          10








          10







          Similar to Ulrike's answer, but using the TeX counter year by default or adding an optional argument for other years.



          I switched also to the NewTColorBox way, providing better argument control, i.e. using #1 as the usual 1st argument for options.



          Of course, there is the caveat, that by recompilation of the file in another year than supposed (i.e. 2018/2019 will be recompiled in, say, 2020/2021) the theyear approach will change the 'time stamp'



          documentclass{article}
          usepackage{lipsum}
          usepackage{xfrac}
          usepackage[most]{tcolorbox}

          newcounter{annee}

          tcbset{titreresume/.style={boxed title style={colframe=black!15,colbacktitle=gray!75,
          leftrule=1.5mm,rightrule=1.5mm,toprule=1.5pt,bottom=0pt,boxsep=1pt}}}

          tcbset{soustitre/.style={subtitle style={colback=black!7,colframe=black!25,
          boxsep=1mm,fontupper={sffamilybfserieslargeselectfontcolor{black!63}}}}}

          NewTColorBox[auto counter]{resume}{+O{}+m+O{theyear}}{%
          %setcounter{annee}{#1}
          minipage boxed title*=-106mm,
          before upper={textcolor{black!63}{sfrac{#3}{thenumexpr#3+1} hfill #2hfillthetcbcounter/pageref{nombre-de-page}}},
          titreresume,soustitre,colframe=black!25,colback=white,leftrule=3mm,rightrule=3mm,toprule=2pt,bottomrule=2pt,left=3pt,right=0pt,top=3mm,
          fonttitle=sffamilybfserieslarge,label={nombre-de-page},
          enhanced,nobeforeafter,lower separated=false,attach boxed title to top center={yshift=-3mm,xshift=-linewidth/5},
          title={normalsize Résumé},#1}

          begin{document}

          begin{resume}{chapitre 1}[2017]
          tcbsubtitle{Définition}

          lipsum[1]
          end{resume}

          clearpage
          begin{resume}{chapitre 1}

          tcbsubtitle{Propriétés}
          lipsum[2]
          end{resume}
          end{document}


          enter image description here






          share|improve this answer















          Similar to Ulrike's answer, but using the TeX counter year by default or adding an optional argument for other years.



          I switched also to the NewTColorBox way, providing better argument control, i.e. using #1 as the usual 1st argument for options.



          Of course, there is the caveat, that by recompilation of the file in another year than supposed (i.e. 2018/2019 will be recompiled in, say, 2020/2021) the theyear approach will change the 'time stamp'



          documentclass{article}
          usepackage{lipsum}
          usepackage{xfrac}
          usepackage[most]{tcolorbox}

          newcounter{annee}

          tcbset{titreresume/.style={boxed title style={colframe=black!15,colbacktitle=gray!75,
          leftrule=1.5mm,rightrule=1.5mm,toprule=1.5pt,bottom=0pt,boxsep=1pt}}}

          tcbset{soustitre/.style={subtitle style={colback=black!7,colframe=black!25,
          boxsep=1mm,fontupper={sffamilybfserieslargeselectfontcolor{black!63}}}}}

          NewTColorBox[auto counter]{resume}{+O{}+m+O{theyear}}{%
          %setcounter{annee}{#1}
          minipage boxed title*=-106mm,
          before upper={textcolor{black!63}{sfrac{#3}{thenumexpr#3+1} hfill #2hfillthetcbcounter/pageref{nombre-de-page}}},
          titreresume,soustitre,colframe=black!25,colback=white,leftrule=3mm,rightrule=3mm,toprule=2pt,bottomrule=2pt,left=3pt,right=0pt,top=3mm,
          fonttitle=sffamilybfserieslarge,label={nombre-de-page},
          enhanced,nobeforeafter,lower separated=false,attach boxed title to top center={yshift=-3mm,xshift=-linewidth/5},
          title={normalsize Résumé},#1}

          begin{document}

          begin{resume}{chapitre 1}[2017]
          tcbsubtitle{Définition}

          lipsum[1]
          end{resume}

          clearpage
          begin{resume}{chapitre 1}

          tcbsubtitle{Propriétés}
          lipsum[2]
          end{resume}
          end{document}


          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 24 '18 at 17:22

























          answered Dec 24 '18 at 16:17









          Christian HupferChristian Hupfer

          151k15199396




          151k15199396













          • The page number at the top right is no longer displayed instead of 1/2 it only appears /2

            – AndréC
            Dec 24 '18 at 16:23






          • 2





            @AndréC: I deleted the [auto counter] feature, I reinstalled it and it works again. you are getting into troubles anyway by using the same label more than once...

            – Christian Hupfer
            Dec 24 '18 at 16:27








          • 4





            +1 just for seeing an answer by you. Frohe Weihnachten!

            – marmot
            Dec 24 '18 at 16:28











          • Indeed, I do not know why this warning appears or how to correct it. LaTeX LaTeX Warning: Label "nombre-de-page" multiply defined. Nevertheless, it works very well with this warning.

            – AndréC
            Dec 24 '18 at 16:33








          • 1





            @AndréC: just in case you have floats on the page etc or the tcolorbox itself is floating, you most likely want to have shipped it out before the next page starts.

            – Christian Hupfer
            Dec 25 '18 at 7:04



















          • The page number at the top right is no longer displayed instead of 1/2 it only appears /2

            – AndréC
            Dec 24 '18 at 16:23






          • 2





            @AndréC: I deleted the [auto counter] feature, I reinstalled it and it works again. you are getting into troubles anyway by using the same label more than once...

            – Christian Hupfer
            Dec 24 '18 at 16:27








          • 4





            +1 just for seeing an answer by you. Frohe Weihnachten!

            – marmot
            Dec 24 '18 at 16:28











          • Indeed, I do not know why this warning appears or how to correct it. LaTeX LaTeX Warning: Label "nombre-de-page" multiply defined. Nevertheless, it works very well with this warning.

            – AndréC
            Dec 24 '18 at 16:33








          • 1





            @AndréC: just in case you have floats on the page etc or the tcolorbox itself is floating, you most likely want to have shipped it out before the next page starts.

            – Christian Hupfer
            Dec 25 '18 at 7:04

















          The page number at the top right is no longer displayed instead of 1/2 it only appears /2

          – AndréC
          Dec 24 '18 at 16:23





          The page number at the top right is no longer displayed instead of 1/2 it only appears /2

          – AndréC
          Dec 24 '18 at 16:23




          2




          2





          @AndréC: I deleted the [auto counter] feature, I reinstalled it and it works again. you are getting into troubles anyway by using the same label more than once...

          – Christian Hupfer
          Dec 24 '18 at 16:27







          @AndréC: I deleted the [auto counter] feature, I reinstalled it and it works again. you are getting into troubles anyway by using the same label more than once...

          – Christian Hupfer
          Dec 24 '18 at 16:27






          4




          4





          +1 just for seeing an answer by you. Frohe Weihnachten!

          – marmot
          Dec 24 '18 at 16:28





          +1 just for seeing an answer by you. Frohe Weihnachten!

          – marmot
          Dec 24 '18 at 16:28













          Indeed, I do not know why this warning appears or how to correct it. LaTeX LaTeX Warning: Label "nombre-de-page" multiply defined. Nevertheless, it works very well with this warning.

          – AndréC
          Dec 24 '18 at 16:33







          Indeed, I do not know why this warning appears or how to correct it. LaTeX LaTeX Warning: Label "nombre-de-page" multiply defined. Nevertheless, it works very well with this warning.

          – AndréC
          Dec 24 '18 at 16:33






          1




          1





          @AndréC: just in case you have floats on the page etc or the tcolorbox itself is floating, you most likely want to have shipped it out before the next page starts.

          – Christian Hupfer
          Dec 25 '18 at 7:04





          @AndréC: just in case you have floats on the page etc or the tcolorbox itself is floating, you most likely want to have shipped it out before the next page starts.

          – Christian Hupfer
          Dec 25 '18 at 7:04


















          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%2f467192%2fhow-to-do-calculations-with-a-latex-counter-in-a-newtcolorbox-environment%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

          Wiesbaden

          Marschland

          Dieringhausen