# How to typeset moon phase symbols?

I would like to add moon phase symbols to a document of mine but could not find a visually pleasing way to do this. Does anyone know how to typeset aesthetic moon phase symbols?

-
possible duplicate of How to look up a math symbol? –  Andrey Vihrov Nov 14 '11 at 12:11
You can use the unicode symbols (e.g. ☽,☾) if you use a font containing these glyphs. –  Marco Nov 14 '11 at 12:18

You could use TikZ for drawing the lunar phases. Here's a command \moon{<day>} that takes the day of the lunar month as an argument and draws the corresponding lunar phase. The symbols scale with the surrounding text, normal TikZ options can be passed using the optional argument, and the standard lunar phase names have been defined as additional macros (\waxingcrescent, \fullmoon, etc.). The code uses the method for drawing 3D circles that Andrew Stacey describes in Drawing simple 3D cylinders in TikZ.

Edit: I've edited the code to draw the moon more accurately (using a sinusoidal function instead of a linear one). You can now also provide a date to the moon macro for which the moon phase will be drawn. Furthermore, the colour of the moon and the sky can be set using the moon colour and sky colour keys. The key southern hemisphere will flip the diagram vertically.

\foreach \d in {0,2,...,30}{%
\d: \moon{\d} \\
}


\moon[scale=10]{2011-11-20}


\moon[scale=10,sky colour=blue!50!black,moon colour=yellow,southern hemisphere]{2011-11-20}


\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calendar,fpu}

\tikzset{
moon colour/.style={
moon fill/.style={
fill=#1
}
},
sky colour/.style={
sky draw/.style={
draw=#1
},
sky fill/.style={
fill=#1
}
},
southern hemisphere/.style={
rotate=180
}
}

\makeatletter
\pgfcalendardatetojulian{2010-01-15}{\c@pgf@counta} % 2010-01-15 07:11 UTC -- http://aa.usno.navy.mil/cgi-bin/aa_moonphases.pl?year=2010&ZZZ=END
\def\synodicmonth{29.530588853}
\newcommand{\moon}[2][]{%
\edef\checkfordate{\noexpand\in@{-}{#2}}%
\checkfordate%
\ifin@%
\pgfcalendardatetojulian{#2}{\c@pgf@countb}%
\pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed}%
\pgfmathsetmacro\dayssincenewmoon{\the\c@pgf@countb-\the\c@pgf@counta-(7/24+11/(24*60))}%
\pgfmathsetmacro\lunarage{mod(\dayssincenewmoon,\synodicmonth)}
\pgfkeys{/pgf/fpu=false}%%
\else%
\def\lunarage{#2}%
\fi%
\pgfmathsetmacro\leftside{ifthenelse(\lunarage<=\synodicmonth/2,cos(360*(\lunarage/\synodicmonth)),1)}%
\pgfmathsetmacro\rightside{ifthenelse(\lunarage<=\synodicmonth/2,-1,-cos(360*(\lunarage/\synodicmonth))}%
\tikz [moon colour=white,sky colour=black,#1]{
\draw [moon fill, sky draw] (0,0) circle [radius=1ex];
\draw [radius=1,sky draw, sky fill,y=1ex] (0,1ex)
arc [x={(\rightside ex,0pt)},start angle=90,delta angle=-90]
arc [x={(\rightside ex,0pt)},start angle=0,delta angle=-90]
arc [x={(\leftside ex,0pt)},start angle=-90,delta angle=90]
arc [x={(\leftside ex,0pt)},start angle=0,delta angle=90]
-- cycle;
}%
}
\newcommand{\newmoon}{\moon{0}}
\newcommand{\waxingcrescent}{\moon{3.5}}
\newcommand{\firstquartermoon}{\moon{7}}
\newcommand{\waxinggibbous}{\moon{10.5}}
\newcommand{\fullmoon}{\moon{14}}
\newcommand{\waninggibbous}{\moon{17.5}}
\newcommand{\thirdquartermoon}{\moon{21}}
\newcommand{\waningcrescent}{\moon{24.5}}
\begin{document}\noindent\raggedleft%
\foreach \d in {0,2,...,30}{%
\d: \moon{\d} \\
}

\

\moon[scale=10]{2011-11-20}

\moon[scale=10,sky colour=blue!50!black,moon colour=yellow,southern hemisphere]{2011-11-20}
\end{document}

-
Very nice indeed! –  egreg Nov 14 '11 at 14:04
What a nice solution. Thanks! –  Ingo Nov 14 '11 at 14:15
Could this be changed to use the eTeX \loccount to avoid using global counters? –  kahen Nov 20 '11 at 13:59
Impressive! Have you considered turning this into a package? –  doncherry Nov 20 '11 at 16:55
This totally rocks. As my musician friends would say: "Sick answer, dude!" –  Todd Lehman Feb 8 '12 at 21:00
For the moon phases you'll find that \usepackage{wasysym} will provide
\fullmoon \leftmoon \newmoon \rightmoon