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.

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;-) – user121799 Jul 22 '18 at 18:07
  • @marmot +1 I'll have to include this date formatting in my beamer theme: tex.stackexchange.com/questions/132370/… :) – user36296 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.... – user121799 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. – user36296 Jul 22 '18 at 18:46

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.