4

Happy Pi day to all non-American applied mathematicians and scientists (like me) who make approximations!

This is in fact TeX related as I have a question, or perhaps a puzzle. How would I make the equation

$\pi \approx \today$

give the output that makes sense, given the appropriate formatting of today's date. Furthermore, suppose the equation were typeset tomorrow, one might like it to output `\pi \neq \today', if you see what I mean. And if it were typeset on March 14, it might give yet a different answer. I'm afraid I don't have any MWEs for these.

GeoffV
  • 834
  • 7
  • 20

1 Answers1

2

You are a bit late, aren't you? ;-) See here for funny posts along these lines. Just kidding. ;-)

Here is something like a more serious answer, based on Heiko's answer here.

\documentclass{article}
\makeatletter
\edef\mydate{% based on https://tex.stackexchange.com/a/422050/121799
  \two@digits\month
  \two@digits\day
}
\makeatother
\begin{document}
\def\piday{0314}
\ifx\mydate\piday%
happy $\pi$ day
\else
sorry, not a $\pi$ day
\fi
\end{document}

OK, here for Europeans. (Sorry for loading TikZ, which is not at all necessary here but I happen to love it. ;-)

\documentclass{article}
\usepackage{tikz}
\makeatletter
\edef\myday{% based on https://tex.stackexchange.com/a/422050/121799
  \two@digits\day
}
\edef\mymonth{
  \two@digits\month
}
\makeatother
\begin{document}
\pgfmathtruncatemacro{\test}{100*\myday/\mymonth}
\def\mypi{314}
\ifx\test\mypi%
happy European $\pi$ day
\else
sorry, not a European $\pi$ day
\fi
\end{document}
  • Works fine for the Pi day celebrated in America by mathematicians, but not for today's Pi day for European scientists :) – GeoffV Jul 22 '18 at 17:50
  • @GeoffV NOW I got the point (even though I am a European marmot;-) –  Jul 22 '18 at 18:07
  • @marmot +1 I'll have to include this date formatting in my beamer theme: https://tex.stackexchange.com/questions/132370/how-to-number-slides-with-an-increasing-number-of-digits-of-pi :) – samcarter_is_at_topanswers.xyz Jul 22 '18 at 18:22
  • @samcarter I should have known because I had upvoted that before... thanks for the +1 ... I'll be happy to remove this if you think the question is a duplicate or so.... –  Jul 22 '18 at 18:44
  • @marmot Not at all a duplicate, please do not remove. I just wanted to mention, that your code is a nice addition to my theme. – samcarter_is_at_topanswers.xyz Jul 22 '18 at 18:46