1

Is there is a way to insert week number instead to type it directly?

My current document code:

\documentclass[a4paper,12pt]{article}

\usepackage{cmap}                   
\usepackage[T2A]{fontenc}           
\usepackage[utf8]{inputenc}         
\usepackage[english]{babel} 

\author{The Author}
\title{Week 12 2014}
\date{\today}


\begin{document}

\maketitle

\end{document}
  • Welcome to TeX.SX! Are you willing to write \calendarweek{28}{5}{2014}? Then have a look on tex.stackexchange.com/a/10950 and put that in your \title{}. If not, you should rephrase your question in order to get a \week{\today} macro. – LaRiFaRi May 28 '14 at 8:45
3

Possible solution taken from here:

% arara: pdflatex

\documentclass{article}
\def\Expr#1{\the\numexpr #1\relax}

\def\Modulonumber#1#2{\Expr{#2-((((#2+(#1/2))/#1)-1)*#1)}}
\def\Divisionnumber#1#2{\Expr{(2*#2-#1)/(2*#1)}}

\def\Mod#1#2{\Modulonumber{\Expr{#2}}{\Expr{#1}}}
\def\Div#1#2{\Divisionnumber{\Expr{#2}}{\Expr{#1}}}

\def\Jday#1#2#3%
    {\Expr{#1+\Div{((153*(\Expr{#2+(12*(\Div{14-#2}{12}))-3}))+2)}
     {5}+365*(\Expr{#3+4800-(\Div{14-#2}{12})})+
      (\Div{\Expr{#3+4800-(\Div{14-#2}{12})}}{4})-
      (\Div{\Expr{#3+4800-(\Div{14-#2}{12})}}{100})+
      (\Div{\Expr{#3+4800-(\Div{14-#2}{12})}}{400})-32045 }}

\def\cwhlp#1#2#3%
    {\Expr{\Mod {\Mod {\Mod {\Expr
     {\Jday{#1}{#2}{#3}+31741-\Mod{\Jday{#1}{#2}{#3}}{7}}}%
     {146097}}{36524}}{1461}}}

\def\calendarweek#1#2#3%
  {\Expr{\Expr{\Div{\Expr{\Mod{\cwhlp{#1}{#2}{#3}-
    \Expr{\Div{\cwhlp{#1}{#2}{#3}}{1460}}}{365}+
         \Expr{\Div{\cwhlp{#1}{#2}{#3}}{1460}}}}{7} +1}}}
\author{The Author}
\title{CW \calendarweek{28}{5}{2014}}
\date{\today}

\begin{document}
\maketitle
\end{document}

enter image description here

  • I've googled for another option but seems \calendarweek macro is single solution for this case. – Roman Kaganovich May 28 '14 at 10:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.