1

I searched on mathematical operations, and found several interesing results, such as sequence, calculations, and future, among many others.

I am interested in an answer similar to this one, but instead of using \today, I would like to set a different date.

The aim is to create a schedule with initial date, say 01/03/2019 (dd/mm/yyy), and use a command or macro, say \nextlec to automatically return the date 7 days ahead (27/03/2019, and so on).

I tried many approach, but didn't get desired result. Could any one give me a MWE, please? Thank you!

My code follows below. Observe that the compilation returns dates alternatedly added 7 and 8 days.

\documentclass{article}
\usepackage{advdate}

%-> Command to set following lectures
\newcounter{lecnum}
\setcounter{lecnum}{-1}

%... Set the first lecture date
\ThisYear{2019}
\ThisMonth{3}
\ThisDay{1}

\newif\iffirst
\newcommand{\nextlec}{%
    \AdvanceDate[7]
    \iffirst
        \AdvanceDate\global\firstfalse
    \else
        \global\firsttrue
    \fi
        \section*{\today}
        \vspace{-5mm}
    }

\begin{document}
\nextlec

\nextlec

\nextlec

\nextlec

\nextlec

\end{document}
3
  • 2
    Please show us which code you have tried so far ...
    – Mensch
    Commented Nov 20, 2018 at 22:30
  • 1
    The answer at the linked question sets the date to March 30, 2015, so not sure exactly what you want. FYI, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. This will also serve as a test case and ensure that the solution actually works for you. That way those trying to help can focus on the solution as opposed to setting up a test case to figure out what you actually want. Commented Nov 20, 2018 at 22:45
  • Yes, guys... I am edditing the question with my code.
    – Brasil
    Commented Nov 21, 2018 at 0:15

1 Answer 1

2

Using some of your code, the following just sets \firstfalse with the first call to \nextlec, otherwise it advances the date. In both instances, it just sets \today as a \section.

enter image description here

\documentclass{article}

\usepackage{advdate}

%... Set the first lecture date
\ThisYear{2019}
\ThisMonth{3}
\ThisDay{1}

\newif\iffirst
\firsttrue
\newcommand{\nextlec}{%
  \iffirst
    \firstfalse
  \else
    \AdvanceDate[7]%
  \fi
  \section*{\today}
}

\begin{document}

\nextlec

\nextlec

\nextlec

\nextlec

\nextlec

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .