The question datetime2 define dates "globally" outside of \begin{document} has been marked as a duplicate of Formatting datetime2 in LaTex to 4th September, 2016 without the current day? but the questions aren't actually duplicates even though the code in the answer of one is a subset of the code from an answer in the other.
The first question is asking how to define dates in the preamble for later use (migrating from datetime
to datetime2
). Although it's been tagged as formatting, the question isn't actually asking how to format the date. The minimal answer to this question is
\documentclass{article}
\usepackage{datetime2}
\DTMsavedate{sample}{2017-01-31}
\begin{document}
\DTMusedate{sample}
\end{document}
The second question is asking how to display the date in a particular format (using either datetime
or, preferably, datetime2
). The minimal answer to this question is
\documentclass{article}
\usepackage[UKenglish]{babel}
\usepackage[useregional]{datetime2}
\DTMlangsetup[en-GB]{ord=raise,monthyearsep={,\space}}
\begin{document}
\today
\end{document}
However, this question provided a slightly modified MWE from the first. When I answered it, I automatically converted the date storage command used in the MWE, so the OP was able to correctly deduce the answer to the other question from it and posted the solution, but the question was then closed as a duplicate.
There was no discussion about the questions being duplicates before the answer was posted, and the first answer to be posted in the second question certainly doesn't answer the first question.
I'm sure I've seen other questions where an answer has taken a subset of code from another answer (although I can't remember examples off the top of my head), follow-on questions quite often contain code from an earlier answer, and if the OP had posted one question with two parts (storing and displaying) it might've triggered an "ask one question per post" comment.
What's the reasoning behind the close vote when there are plenty of follow-on questions that expand on an answer to an earlier question?