How to calculate the current school year in a tcolorbox?












2















I have created a personal package that contains the definition of a summary box.



This box has an optional argument that is the current school year (highlighted in yellow in the screenshot below).



année scolaire



suite



I would like to be able to calculate the current school year automatically.




  • Thus, for a compilation between September 1, 2018 and August 31, 2019, the school year displayed is 2018/2019 by default.

  • Otherwise, if this option is set to 2017, it will display as it does today 2017/2018.


How can this be achieved?



The current code is the one of @jbfu's response:



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

%%%%%%%%%%%%%%%%%%%%%%%%%%%
% boite resumé

defcouleurresume{red}%

% style du titre « résumé du cours »
tcbset{titreresume/.style={
boxed title style={
colframe=couleurresume!50,%
colback=couleurresume!10,%
coltext=blue,%
leftrule=1.5mm,rightrule=1.5mm,toprule=1.5pt,bottom=0pt,boxsep=1pt}}
}

% style des soustitres des résumés
tcbset{soustitre/.style={
subtitle style={%
colback=couleurresume!7,%
colframe=couleurresume!50,%
boxsep=1mm,
fontupper={sffamilybfserieslargeselectfontcolor{couleurresume!63!black}}}}
}

% style du titre-boxed des encadrés
tcbset{titrecadre/.style={%
minipage boxed title*=-.5linewidth,
boxed title style={
boxrule=.8pt,boxsep=0pt,toptitle=0pt,
colframe=couleurresume!55,colback=white},
halign title=left}
}

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


usepackage{atveryend}
makeatletter
AfterLastShipout{%
immediatewrite@auxout
{stringnewlabel{nombre-de-resume}{{thetcb@cnt@resume}{}}}%
}
makeatother
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}

%showtcbcounter
end{document}









share|improve this question



























    2















    I have created a personal package that contains the definition of a summary box.



    This box has an optional argument that is the current school year (highlighted in yellow in the screenshot below).



    année scolaire



    suite



    I would like to be able to calculate the current school year automatically.




    • Thus, for a compilation between September 1, 2018 and August 31, 2019, the school year displayed is 2018/2019 by default.

    • Otherwise, if this option is set to 2017, it will display as it does today 2017/2018.


    How can this be achieved?



    The current code is the one of @jbfu's response:



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

    %%%%%%%%%%%%%%%%%%%%%%%%%%%
    % boite resumé

    defcouleurresume{red}%

    % style du titre « résumé du cours »
    tcbset{titreresume/.style={
    boxed title style={
    colframe=couleurresume!50,%
    colback=couleurresume!10,%
    coltext=blue,%
    leftrule=1.5mm,rightrule=1.5mm,toprule=1.5pt,bottom=0pt,boxsep=1pt}}
    }

    % style des soustitres des résumés
    tcbset{soustitre/.style={
    subtitle style={%
    colback=couleurresume!7,%
    colframe=couleurresume!50,%
    boxsep=1mm,
    fontupper={sffamilybfserieslargeselectfontcolor{couleurresume!63!black}}}}
    }

    % style du titre-boxed des encadrés
    tcbset{titrecadre/.style={%
    minipage boxed title*=-.5linewidth,
    boxed title style={
    boxrule=.8pt,boxsep=0pt,toptitle=0pt,
    colframe=couleurresume!55,colback=white},
    halign title=left}
    }

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


    usepackage{atveryend}
    makeatletter
    AfterLastShipout{%
    immediatewrite@auxout
    {stringnewlabel{nombre-de-resume}{{thetcb@cnt@resume}{}}}%
    }
    makeatother
    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}

    %showtcbcounter
    end{document}









    share|improve this question

























      2












      2








      2


      1






      I have created a personal package that contains the definition of a summary box.



      This box has an optional argument that is the current school year (highlighted in yellow in the screenshot below).



      année scolaire



      suite



      I would like to be able to calculate the current school year automatically.




      • Thus, for a compilation between September 1, 2018 and August 31, 2019, the school year displayed is 2018/2019 by default.

      • Otherwise, if this option is set to 2017, it will display as it does today 2017/2018.


      How can this be achieved?



      The current code is the one of @jbfu's response:



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

      %%%%%%%%%%%%%%%%%%%%%%%%%%%
      % boite resumé

      defcouleurresume{red}%

      % style du titre « résumé du cours »
      tcbset{titreresume/.style={
      boxed title style={
      colframe=couleurresume!50,%
      colback=couleurresume!10,%
      coltext=blue,%
      leftrule=1.5mm,rightrule=1.5mm,toprule=1.5pt,bottom=0pt,boxsep=1pt}}
      }

      % style des soustitres des résumés
      tcbset{soustitre/.style={
      subtitle style={%
      colback=couleurresume!7,%
      colframe=couleurresume!50,%
      boxsep=1mm,
      fontupper={sffamilybfserieslargeselectfontcolor{couleurresume!63!black}}}}
      }

      % style du titre-boxed des encadrés
      tcbset{titrecadre/.style={%
      minipage boxed title*=-.5linewidth,
      boxed title style={
      boxrule=.8pt,boxsep=0pt,toptitle=0pt,
      colframe=couleurresume!55,colback=white},
      halign title=left}
      }

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


      usepackage{atveryend}
      makeatletter
      AfterLastShipout{%
      immediatewrite@auxout
      {stringnewlabel{nombre-de-resume}{{thetcb@cnt@resume}{}}}%
      }
      makeatother
      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}

      %showtcbcounter
      end{document}









      share|improve this question














      I have created a personal package that contains the definition of a summary box.



      This box has an optional argument that is the current school year (highlighted in yellow in the screenshot below).



      année scolaire



      suite



      I would like to be able to calculate the current school year automatically.




      • Thus, for a compilation between September 1, 2018 and August 31, 2019, the school year displayed is 2018/2019 by default.

      • Otherwise, if this option is set to 2017, it will display as it does today 2017/2018.


      How can this be achieved?



      The current code is the one of @jbfu's response:



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

      %%%%%%%%%%%%%%%%%%%%%%%%%%%
      % boite resumé

      defcouleurresume{red}%

      % style du titre « résumé du cours »
      tcbset{titreresume/.style={
      boxed title style={
      colframe=couleurresume!50,%
      colback=couleurresume!10,%
      coltext=blue,%
      leftrule=1.5mm,rightrule=1.5mm,toprule=1.5pt,bottom=0pt,boxsep=1pt}}
      }

      % style des soustitres des résumés
      tcbset{soustitre/.style={
      subtitle style={%
      colback=couleurresume!7,%
      colframe=couleurresume!50,%
      boxsep=1mm,
      fontupper={sffamilybfserieslargeselectfontcolor{couleurresume!63!black}}}}
      }

      % style du titre-boxed des encadrés
      tcbset{titrecadre/.style={%
      minipage boxed title*=-.5linewidth,
      boxed title style={
      boxrule=.8pt,boxsep=0pt,toptitle=0pt,
      colframe=couleurresume!55,colback=white},
      halign title=left}
      }

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


      usepackage{atveryend}
      makeatletter
      AfterLastShipout{%
      immediatewrite@auxout
      {stringnewlabel{nombre-de-resume}{{thetcb@cnt@resume}{}}}%
      }
      makeatother
      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}

      %showtcbcounter
      end{document}






      tcolorbox






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 1 hour ago









      AndréCAndréC

      8,50111446




      8,50111446






















          1 Answer
          1






          active

          oldest

          votes


















          5














          enter image description here



          enter image description here



          Here is a way with NewDocumentCommand and checking the year and month counter registers.



          Apparently a school year is pretty much exactly one year in France (so different to Germany, where it usually begins in August/September and ends in June/July -- school's out for summer is not counted here)



          currentschoolyear has one optional argument, tested with IfValueTF -- without the argument, the month is whether it is smaller than 9 if this is the case, it is the time from January to August, so it is the current school year at that period, if month is 9 or larger, the value advances to the next year, i.e. 2019/09/21 would give 2019/2020, whereas 2019/05/21 will return 2018/2019.



          NewDocumentCommand{currentschoolyear}{+o}{%
          IfValueTF{#1}{%
          sfrac{#1}{thenumexpr#1+1}%
          }{%
          ifnummonth<9%
          sfrac{thenumexpryear-1}{theyear}%
          else
          sfrac{theyear}{thenumexpryear+1}%
          fi
          }%
          }


          In order to test for empty arguments from the tcolorbox environment either use ifblank (a etoolbox macro) or switch over to the more sophisticated NewTColorBox macro that allows checks for xparse - like argument specifiers.



          month=9 can be used in order to explicitly set the month, if needed.



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

          NewDocumentCommand{currentschoolyear}{+o}{%
          IfValueTF{#1}{%
          sfrac{#1}{thenumexpr#1+1}
          }{%
          ifnummonth<9%
          ifnumday<32
          sfrac{thenumexpryear-1}{theyear}%
          fi
          else
          sfrac{theyear}{thenumexpryear+1}%
          fi
          }%
          }

          %month=7
          %day=31

          %%%%%%%%%%%%%%%%%%%%%%%%%%%
          % boite resumé

          defcouleurresume{red}%

          % style du titre « résumé du cours »
          tcbset{titreresume/.style={
          boxed title style={
          colframe=couleurresume!50,%
          colback=couleurresume!10,%
          coltext=blue,%
          leftrule=1.5mm,rightrule=1.5mm,toprule=1.5pt,bottom=0pt,boxsep=1pt}}
          }

          % style des soustitres des résumés
          tcbset{soustitre/.style={
          subtitle style={%
          colback=couleurresume!7,%
          colframe=couleurresume!50,%
          boxsep=1mm,
          fontupper={sffamilybfserieslargeselectfontcolor{couleurresume!63!black}}}}
          }

          % style du titre-boxed des encadrés
          tcbset{titrecadre/.style={%
          minipage boxed title*=-.5linewidth,
          boxed title style={
          boxrule=.8pt,boxsep=0pt,toptitle=0pt,
          colframe=couleurresume!55,colback=white},
          halign title=left}
          }

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

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

          usepackage{atveryend}
          makeatletter
          AfterLastShipout{%
          immediatewrite@auxout
          {stringnewlabel{nombre-de-resume}{{thetcb@cnt@resume}{}}}%
          }
          makeatother
          begin{document}

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

          lipsum[1]
          end{resume}

          newpage

          begin{resume}{chapitre 1}

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

          %showtcbcounter
          end{document}





          share|improve this answer


























          • To my knowledge, the school year does not have a legal definition in France. The start dates and the summer holiday date are defined. These dates vary each year. Currently, teachers return to school on the last day of August. So, to simplify, I prefer to pretend that a school year lasts a full year. This will allow me to correct the previous year's documents without having to change the default option.

            – AndréC
            30 mins ago











          • @AndréC: In my federal state here in Germany, school always ends at end of July and starts mid of september. I don't bother about the correct dates however. The code I gave above is what I use basically in my LaTeX code suite for my work at school.

            – Christian Hupfer
            26 mins ago











          • 50 years ago in France, it was the same as in Germany. It allowed the children of farmers (very many at the time) to help their parents in the fields. From now on, summer holidays are getting shorter and shorter so that the official summer holiday date is July 6, 2019! The Ministry and many unions want this holiday to be even shorter, but the tourism industry is not in favour of it (and neither am I).

            – AndréC
            22 mins ago











          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%2f470931%2fhow-to-calculate-the-current-school-year-in-a-tcolorbox%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









          5














          enter image description here



          enter image description here



          Here is a way with NewDocumentCommand and checking the year and month counter registers.



          Apparently a school year is pretty much exactly one year in France (so different to Germany, where it usually begins in August/September and ends in June/July -- school's out for summer is not counted here)



          currentschoolyear has one optional argument, tested with IfValueTF -- without the argument, the month is whether it is smaller than 9 if this is the case, it is the time from January to August, so it is the current school year at that period, if month is 9 or larger, the value advances to the next year, i.e. 2019/09/21 would give 2019/2020, whereas 2019/05/21 will return 2018/2019.



          NewDocumentCommand{currentschoolyear}{+o}{%
          IfValueTF{#1}{%
          sfrac{#1}{thenumexpr#1+1}%
          }{%
          ifnummonth<9%
          sfrac{thenumexpryear-1}{theyear}%
          else
          sfrac{theyear}{thenumexpryear+1}%
          fi
          }%
          }


          In order to test for empty arguments from the tcolorbox environment either use ifblank (a etoolbox macro) or switch over to the more sophisticated NewTColorBox macro that allows checks for xparse - like argument specifiers.



          month=9 can be used in order to explicitly set the month, if needed.



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

          NewDocumentCommand{currentschoolyear}{+o}{%
          IfValueTF{#1}{%
          sfrac{#1}{thenumexpr#1+1}
          }{%
          ifnummonth<9%
          ifnumday<32
          sfrac{thenumexpryear-1}{theyear}%
          fi
          else
          sfrac{theyear}{thenumexpryear+1}%
          fi
          }%
          }

          %month=7
          %day=31

          %%%%%%%%%%%%%%%%%%%%%%%%%%%
          % boite resumé

          defcouleurresume{red}%

          % style du titre « résumé du cours »
          tcbset{titreresume/.style={
          boxed title style={
          colframe=couleurresume!50,%
          colback=couleurresume!10,%
          coltext=blue,%
          leftrule=1.5mm,rightrule=1.5mm,toprule=1.5pt,bottom=0pt,boxsep=1pt}}
          }

          % style des soustitres des résumés
          tcbset{soustitre/.style={
          subtitle style={%
          colback=couleurresume!7,%
          colframe=couleurresume!50,%
          boxsep=1mm,
          fontupper={sffamilybfserieslargeselectfontcolor{couleurresume!63!black}}}}
          }

          % style du titre-boxed des encadrés
          tcbset{titrecadre/.style={%
          minipage boxed title*=-.5linewidth,
          boxed title style={
          boxrule=.8pt,boxsep=0pt,toptitle=0pt,
          colframe=couleurresume!55,colback=white},
          halign title=left}
          }

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

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

          usepackage{atveryend}
          makeatletter
          AfterLastShipout{%
          immediatewrite@auxout
          {stringnewlabel{nombre-de-resume}{{thetcb@cnt@resume}{}}}%
          }
          makeatother
          begin{document}

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

          lipsum[1]
          end{resume}

          newpage

          begin{resume}{chapitre 1}

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

          %showtcbcounter
          end{document}





          share|improve this answer


























          • To my knowledge, the school year does not have a legal definition in France. The start dates and the summer holiday date are defined. These dates vary each year. Currently, teachers return to school on the last day of August. So, to simplify, I prefer to pretend that a school year lasts a full year. This will allow me to correct the previous year's documents without having to change the default option.

            – AndréC
            30 mins ago











          • @AndréC: In my federal state here in Germany, school always ends at end of July and starts mid of september. I don't bother about the correct dates however. The code I gave above is what I use basically in my LaTeX code suite for my work at school.

            – Christian Hupfer
            26 mins ago











          • 50 years ago in France, it was the same as in Germany. It allowed the children of farmers (very many at the time) to help their parents in the fields. From now on, summer holidays are getting shorter and shorter so that the official summer holiday date is July 6, 2019! The Ministry and many unions want this holiday to be even shorter, but the tourism industry is not in favour of it (and neither am I).

            – AndréC
            22 mins ago
















          5














          enter image description here



          enter image description here



          Here is a way with NewDocumentCommand and checking the year and month counter registers.



          Apparently a school year is pretty much exactly one year in France (so different to Germany, where it usually begins in August/September and ends in June/July -- school's out for summer is not counted here)



          currentschoolyear has one optional argument, tested with IfValueTF -- without the argument, the month is whether it is smaller than 9 if this is the case, it is the time from January to August, so it is the current school year at that period, if month is 9 or larger, the value advances to the next year, i.e. 2019/09/21 would give 2019/2020, whereas 2019/05/21 will return 2018/2019.



          NewDocumentCommand{currentschoolyear}{+o}{%
          IfValueTF{#1}{%
          sfrac{#1}{thenumexpr#1+1}%
          }{%
          ifnummonth<9%
          sfrac{thenumexpryear-1}{theyear}%
          else
          sfrac{theyear}{thenumexpryear+1}%
          fi
          }%
          }


          In order to test for empty arguments from the tcolorbox environment either use ifblank (a etoolbox macro) or switch over to the more sophisticated NewTColorBox macro that allows checks for xparse - like argument specifiers.



          month=9 can be used in order to explicitly set the month, if needed.



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

          NewDocumentCommand{currentschoolyear}{+o}{%
          IfValueTF{#1}{%
          sfrac{#1}{thenumexpr#1+1}
          }{%
          ifnummonth<9%
          ifnumday<32
          sfrac{thenumexpryear-1}{theyear}%
          fi
          else
          sfrac{theyear}{thenumexpryear+1}%
          fi
          }%
          }

          %month=7
          %day=31

          %%%%%%%%%%%%%%%%%%%%%%%%%%%
          % boite resumé

          defcouleurresume{red}%

          % style du titre « résumé du cours »
          tcbset{titreresume/.style={
          boxed title style={
          colframe=couleurresume!50,%
          colback=couleurresume!10,%
          coltext=blue,%
          leftrule=1.5mm,rightrule=1.5mm,toprule=1.5pt,bottom=0pt,boxsep=1pt}}
          }

          % style des soustitres des résumés
          tcbset{soustitre/.style={
          subtitle style={%
          colback=couleurresume!7,%
          colframe=couleurresume!50,%
          boxsep=1mm,
          fontupper={sffamilybfserieslargeselectfontcolor{couleurresume!63!black}}}}
          }

          % style du titre-boxed des encadrés
          tcbset{titrecadre/.style={%
          minipage boxed title*=-.5linewidth,
          boxed title style={
          boxrule=.8pt,boxsep=0pt,toptitle=0pt,
          colframe=couleurresume!55,colback=white},
          halign title=left}
          }

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

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

          usepackage{atveryend}
          makeatletter
          AfterLastShipout{%
          immediatewrite@auxout
          {stringnewlabel{nombre-de-resume}{{thetcb@cnt@resume}{}}}%
          }
          makeatother
          begin{document}

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

          lipsum[1]
          end{resume}

          newpage

          begin{resume}{chapitre 1}

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

          %showtcbcounter
          end{document}





          share|improve this answer


























          • To my knowledge, the school year does not have a legal definition in France. The start dates and the summer holiday date are defined. These dates vary each year. Currently, teachers return to school on the last day of August. So, to simplify, I prefer to pretend that a school year lasts a full year. This will allow me to correct the previous year's documents without having to change the default option.

            – AndréC
            30 mins ago











          • @AndréC: In my federal state here in Germany, school always ends at end of July and starts mid of september. I don't bother about the correct dates however. The code I gave above is what I use basically in my LaTeX code suite for my work at school.

            – Christian Hupfer
            26 mins ago











          • 50 years ago in France, it was the same as in Germany. It allowed the children of farmers (very many at the time) to help their parents in the fields. From now on, summer holidays are getting shorter and shorter so that the official summer holiday date is July 6, 2019! The Ministry and many unions want this holiday to be even shorter, but the tourism industry is not in favour of it (and neither am I).

            – AndréC
            22 mins ago














          5












          5








          5







          enter image description here



          enter image description here



          Here is a way with NewDocumentCommand and checking the year and month counter registers.



          Apparently a school year is pretty much exactly one year in France (so different to Germany, where it usually begins in August/September and ends in June/July -- school's out for summer is not counted here)



          currentschoolyear has one optional argument, tested with IfValueTF -- without the argument, the month is whether it is smaller than 9 if this is the case, it is the time from January to August, so it is the current school year at that period, if month is 9 or larger, the value advances to the next year, i.e. 2019/09/21 would give 2019/2020, whereas 2019/05/21 will return 2018/2019.



          NewDocumentCommand{currentschoolyear}{+o}{%
          IfValueTF{#1}{%
          sfrac{#1}{thenumexpr#1+1}%
          }{%
          ifnummonth<9%
          sfrac{thenumexpryear-1}{theyear}%
          else
          sfrac{theyear}{thenumexpryear+1}%
          fi
          }%
          }


          In order to test for empty arguments from the tcolorbox environment either use ifblank (a etoolbox macro) or switch over to the more sophisticated NewTColorBox macro that allows checks for xparse - like argument specifiers.



          month=9 can be used in order to explicitly set the month, if needed.



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

          NewDocumentCommand{currentschoolyear}{+o}{%
          IfValueTF{#1}{%
          sfrac{#1}{thenumexpr#1+1}
          }{%
          ifnummonth<9%
          ifnumday<32
          sfrac{thenumexpryear-1}{theyear}%
          fi
          else
          sfrac{theyear}{thenumexpryear+1}%
          fi
          }%
          }

          %month=7
          %day=31

          %%%%%%%%%%%%%%%%%%%%%%%%%%%
          % boite resumé

          defcouleurresume{red}%

          % style du titre « résumé du cours »
          tcbset{titreresume/.style={
          boxed title style={
          colframe=couleurresume!50,%
          colback=couleurresume!10,%
          coltext=blue,%
          leftrule=1.5mm,rightrule=1.5mm,toprule=1.5pt,bottom=0pt,boxsep=1pt}}
          }

          % style des soustitres des résumés
          tcbset{soustitre/.style={
          subtitle style={%
          colback=couleurresume!7,%
          colframe=couleurresume!50,%
          boxsep=1mm,
          fontupper={sffamilybfserieslargeselectfontcolor{couleurresume!63!black}}}}
          }

          % style du titre-boxed des encadrés
          tcbset{titrecadre/.style={%
          minipage boxed title*=-.5linewidth,
          boxed title style={
          boxrule=.8pt,boxsep=0pt,toptitle=0pt,
          colframe=couleurresume!55,colback=white},
          halign title=left}
          }

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

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

          usepackage{atveryend}
          makeatletter
          AfterLastShipout{%
          immediatewrite@auxout
          {stringnewlabel{nombre-de-resume}{{thetcb@cnt@resume}{}}}%
          }
          makeatother
          begin{document}

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

          lipsum[1]
          end{resume}

          newpage

          begin{resume}{chapitre 1}

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

          %showtcbcounter
          end{document}





          share|improve this answer















          enter image description here



          enter image description here



          Here is a way with NewDocumentCommand and checking the year and month counter registers.



          Apparently a school year is pretty much exactly one year in France (so different to Germany, where it usually begins in August/September and ends in June/July -- school's out for summer is not counted here)



          currentschoolyear has one optional argument, tested with IfValueTF -- without the argument, the month is whether it is smaller than 9 if this is the case, it is the time from January to August, so it is the current school year at that period, if month is 9 or larger, the value advances to the next year, i.e. 2019/09/21 would give 2019/2020, whereas 2019/05/21 will return 2018/2019.



          NewDocumentCommand{currentschoolyear}{+o}{%
          IfValueTF{#1}{%
          sfrac{#1}{thenumexpr#1+1}%
          }{%
          ifnummonth<9%
          sfrac{thenumexpryear-1}{theyear}%
          else
          sfrac{theyear}{thenumexpryear+1}%
          fi
          }%
          }


          In order to test for empty arguments from the tcolorbox environment either use ifblank (a etoolbox macro) or switch over to the more sophisticated NewTColorBox macro that allows checks for xparse - like argument specifiers.



          month=9 can be used in order to explicitly set the month, if needed.



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

          NewDocumentCommand{currentschoolyear}{+o}{%
          IfValueTF{#1}{%
          sfrac{#1}{thenumexpr#1+1}
          }{%
          ifnummonth<9%
          ifnumday<32
          sfrac{thenumexpryear-1}{theyear}%
          fi
          else
          sfrac{theyear}{thenumexpryear+1}%
          fi
          }%
          }

          %month=7
          %day=31

          %%%%%%%%%%%%%%%%%%%%%%%%%%%
          % boite resumé

          defcouleurresume{red}%

          % style du titre « résumé du cours »
          tcbset{titreresume/.style={
          boxed title style={
          colframe=couleurresume!50,%
          colback=couleurresume!10,%
          coltext=blue,%
          leftrule=1.5mm,rightrule=1.5mm,toprule=1.5pt,bottom=0pt,boxsep=1pt}}
          }

          % style des soustitres des résumés
          tcbset{soustitre/.style={
          subtitle style={%
          colback=couleurresume!7,%
          colframe=couleurresume!50,%
          boxsep=1mm,
          fontupper={sffamilybfserieslargeselectfontcolor{couleurresume!63!black}}}}
          }

          % style du titre-boxed des encadrés
          tcbset{titrecadre/.style={%
          minipage boxed title*=-.5linewidth,
          boxed title style={
          boxrule=.8pt,boxsep=0pt,toptitle=0pt,
          colframe=couleurresume!55,colback=white},
          halign title=left}
          }

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

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

          usepackage{atveryend}
          makeatletter
          AfterLastShipout{%
          immediatewrite@auxout
          {stringnewlabel{nombre-de-resume}{{thetcb@cnt@resume}{}}}%
          }
          makeatother
          begin{document}

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

          lipsum[1]
          end{resume}

          newpage

          begin{resume}{chapitre 1}

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

          %showtcbcounter
          end{document}






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 32 mins ago

























          answered 44 mins ago









          Christian HupferChristian Hupfer

          149k14195390




          149k14195390













          • To my knowledge, the school year does not have a legal definition in France. The start dates and the summer holiday date are defined. These dates vary each year. Currently, teachers return to school on the last day of August. So, to simplify, I prefer to pretend that a school year lasts a full year. This will allow me to correct the previous year's documents without having to change the default option.

            – AndréC
            30 mins ago











          • @AndréC: In my federal state here in Germany, school always ends at end of July and starts mid of september. I don't bother about the correct dates however. The code I gave above is what I use basically in my LaTeX code suite for my work at school.

            – Christian Hupfer
            26 mins ago











          • 50 years ago in France, it was the same as in Germany. It allowed the children of farmers (very many at the time) to help their parents in the fields. From now on, summer holidays are getting shorter and shorter so that the official summer holiday date is July 6, 2019! The Ministry and many unions want this holiday to be even shorter, but the tourism industry is not in favour of it (and neither am I).

            – AndréC
            22 mins ago



















          • To my knowledge, the school year does not have a legal definition in France. The start dates and the summer holiday date are defined. These dates vary each year. Currently, teachers return to school on the last day of August. So, to simplify, I prefer to pretend that a school year lasts a full year. This will allow me to correct the previous year's documents without having to change the default option.

            – AndréC
            30 mins ago











          • @AndréC: In my federal state here in Germany, school always ends at end of July and starts mid of september. I don't bother about the correct dates however. The code I gave above is what I use basically in my LaTeX code suite for my work at school.

            – Christian Hupfer
            26 mins ago











          • 50 years ago in France, it was the same as in Germany. It allowed the children of farmers (very many at the time) to help their parents in the fields. From now on, summer holidays are getting shorter and shorter so that the official summer holiday date is July 6, 2019! The Ministry and many unions want this holiday to be even shorter, but the tourism industry is not in favour of it (and neither am I).

            – AndréC
            22 mins ago

















          To my knowledge, the school year does not have a legal definition in France. The start dates and the summer holiday date are defined. These dates vary each year. Currently, teachers return to school on the last day of August. So, to simplify, I prefer to pretend that a school year lasts a full year. This will allow me to correct the previous year's documents without having to change the default option.

          – AndréC
          30 mins ago





          To my knowledge, the school year does not have a legal definition in France. The start dates and the summer holiday date are defined. These dates vary each year. Currently, teachers return to school on the last day of August. So, to simplify, I prefer to pretend that a school year lasts a full year. This will allow me to correct the previous year's documents without having to change the default option.

          – AndréC
          30 mins ago













          @AndréC: In my federal state here in Germany, school always ends at end of July and starts mid of september. I don't bother about the correct dates however. The code I gave above is what I use basically in my LaTeX code suite for my work at school.

          – Christian Hupfer
          26 mins ago





          @AndréC: In my federal state here in Germany, school always ends at end of July and starts mid of september. I don't bother about the correct dates however. The code I gave above is what I use basically in my LaTeX code suite for my work at school.

          – Christian Hupfer
          26 mins ago













          50 years ago in France, it was the same as in Germany. It allowed the children of farmers (very many at the time) to help their parents in the fields. From now on, summer holidays are getting shorter and shorter so that the official summer holiday date is July 6, 2019! The Ministry and many unions want this holiday to be even shorter, but the tourism industry is not in favour of it (and neither am I).

          – AndréC
          22 mins ago





          50 years ago in France, it was the same as in Germany. It allowed the children of farmers (very many at the time) to help their parents in the fields. From now on, summer holidays are getting shorter and shorter so that the official summer holiday date is July 6, 2019! The Ministry and many unions want this holiday to be even shorter, but the tourism industry is not in favour of it (and neither am I).

          – AndréC
          22 mins ago


















          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%2f470931%2fhow-to-calculate-the-current-school-year-in-a-tcolorbox%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

          404 Error Contact Form 7 ajax form submitting

          How to know if a Active Directory user can login interactively

          TypeError: fit_transform() missing 1 required positional argument: 'X'