1

This question already has an answer here:

I am trying to make a vertical column of various moon phases using a macro that generates circles, but when I add a node label to a circle (to designates that it is a full moon) it shifts the circle that contains the label slightly to the right.

\documentclass[leqno,12pt]{article}
\usepackage{tikz}
\usetikzlibrary{calendar,fpu}

\newcommand{\moon}[2][]{%
    \def\lunarage{#2}%
    \pgfmathsetmacro\textF{ifthenelse(\lunarage==15,"F","")}
    \tikz []{
        \draw (0,0) circle [radius=1ex];
        \node[color=black] (0,0) {\textF};
        %
    }%
}
\begin{document}\noindent%
    \foreach \d in {0,1,...,30}{%
    \moon[]{\d}  \\   }
\end{document}

THANKS for any help!

marked as duplicate by Ignasi, Andrew Swann, ChrisS, Svend Tveskæg, Paul Gaborit Mar 9 '16 at 9:29

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

The problem is the size of your nodes. Those are wider (and higher) than the label, thereby making the tikzpicture slightly wider, which results in the shift (your tikz-environments are left aligned). If you set inner sep and outer sep to zero, you get the desired result:

\documentclass[leqno,12pt]{article}
\usepackage{tikz}
\usetikzlibrary{calendar,fpu}

\newcommand{\moon}[2][]{%
    \def\lunarage{#2}%
    \pgfmathsetmacro\textF{ifthenelse(\lunarage==15,"F","")}
    \tikz []{
        \draw (0,0) circle [radius=1ex];
        \node[color=black, inner sep=0pt, outer sep=0pt] (0,0) {\textF};
        %
    }%
}
\begin{document}\noindent%
    \foreach \d in {0,1,...,30}{%
    \moon[]{\d}  \\   }
\end{document}

See page 220 in the pgfmanual version 3.0.0.

Not the answer you're looking for? Browse other questions tagged or ask your own question.