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?
[Tex/LaTex] How to typeset moon phase symbols
symbols
Related Solutions
The following example composes \boxast
from \Box
and *
and only needs package amssymb
because of \Box
:
\documentclass{article}
\usepackage{amssymb}
\makeatletter
\providecommand*{\boxast}{%
\mathbin{% as \boxplus and \boxtimes
\mathpalette\@boxit{*}%
}%
}
\newcommand*{\@boxit}[2]{%
% #1: math style (\displaystyle, \textstyle, ...)
% #2: symbol to be boxed that is centered around the math axis
\sbox0{$\m@th#1\Box$}%
% Manual correction for font bounding boxes:
\ifx#1\displaystyle \ht0=\dimexpr\ht0+.05ex\relax \fi
\ifx#1\textstyle \ht0=\dimexpr\ht0+.05ex\relax \fi
\ifx#1\scriptstyle \ht0=\dimexpr\ht0+.04ex\relax \fi
\ifx#1\scriptscriptstyle \ht0=\dimexpr\ht0+.065ex\relax \fi
\sbox2{$#1\vcenter{}$}% \ht2 is positionn of math axis
\rlap{%
\hbox to \wd0{%
\hfill
\raisebox{%
\dimexpr.5\dimexpr\ht0+\dp0\relax-\ht2\relax
}{$\m@th#1#2$}%
\hfill
}%
}%
\Box
}
\makeatother
\begin{document}
$A \boxplus B \boxast C^{D \boxast E^{F \boxast G}}$
\end{document}
Remarks:
Macro
\@boxit
assumes that the symbol to be boxed is centered around the math axis as some of the typical boxed symbols are (plus, minus, times, ast). Then the symbol is placed in the middle of the box. (There might be tiny deviations because glyph side bearings are not taken into account.)The reason for
\mathpalette
is to get the actual math style in order to match the size of the symbol according to the current math style.\m@th
removes\mathsurround
, because it should add space around the formula, not within, if\mathsurround
is set.Update: The font bounding box of
\Box
is a little too small in the height, therefore I have added a manual correction.The following file shows the font bounding boxes for
\Box
, first the unmodified font bounding box (red), then the corrected bounding box (green). (The larger width of the font bounding box does not matter, because the white space left and right seems to be the same and the symbol remains centered.)\documentclass{article} \usepackage{amssymb} \usepackage{color} \begin{document} \setlength{\fboxsep}{0pt} \setlength{\fboxrule}{.1pt} \newcommand*{\test}[2]{% \fbox{\color{red}$\csname #1style\endcsname\Box$}% \fbox{\color{green}% $\csname #1style\endcsname\Box$% \vphantom{\raisebox{#2}{$\csname #1style\endcsname\Box$}}% }% } \newcommand*{\test}[1]{% \fbox{\color{blue}$\csname #1style\endcsname\Box$}% } \test{display} \test{text} \test{script} \test{scriptscript} \end{document}
A poorman’s version:
\documentclass{article}
\usepackage{graphicx}
\makeatletter
\DeclareRobustCommand{\versicle}{\vers@resp{-0.1em}{V}}
\DeclareRobustCommand{\response}{\vers@resp{0pt}{R}}
\newcommand{\vers@resp@sym}{\raisebox{0.2ex}{\rotatebox[origin=c]{-20}{$\m@th\rceil$}}}
\newcommand{\vers@resp}[2]{%
{\ooalign{\hidewidth\kern#1\vers@resp@sym\hidewidth\cr#2\cr}}%
}
\makeatother
\begin{document}
\versicle
\response
\end{document}
You may need to fine tune the parameters for a different font.
Best Answer
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 themoon colour
andsky colour
keys. The keysouthern hemisphere
will flip the diagram vertically.