12

I am trying to draw simple empty, half-filled and fully filled circles using tikz. Here is what my code:

\documentclass[12pt]{article}

\usepackage{tikz}
\newcommand*\emptycirc{\tikz\draw (0,0) circle (1.0ex);} 
\newcommand*\halfcirc{\tikz\draw[fill] (0,0)-- (90:1ex) arc (90:270:1ex) -- cycle ;}
\newcommand*\fullcirc{\tikz\fill (0,0) circle (1.0ex);} 

\begin{document}

\begin{tabular}{|c|}
            \hline
            \emptycirc\\ \hline
            \halfcirc \\ \hline
            \fullcirc \\ \hline
        \end{tabular}

\end{document}

I want to achieve following two aspects in terms of half circle. I want

  • the halfcirc to show rest of the circle
  • I want to control radius of the half-circle, similar to circle (1.0ex).

Many trials, nothing worked.

2

3 Answers 3

14
\documentclass[12pt]{article}

\usepackage{tikz}
\newcommand*\emptycirc[1][1ex]{\tikz\draw (0,0) circle (#1);} 
\newcommand*\halfcirc[1][1ex]{%
  \begin{tikzpicture}
  \draw[fill] (0,0)-- (90:#1) arc (90:270:#1) -- cycle ;
  \draw (0,0) circle (#1);
  \end{tikzpicture}}
\newcommand*\fullcirc[1][1ex]{\tikz\fill (0,0) circle (#1);} 

\begin{document}

\begin{tabular}{|c|}
            \hline
            \emptycirc \emptycirc[2ex]\\ \hline
            \halfcirc \halfcirc[2ex]\\ \hline
            \fullcirc \fullcirc[2ex]\\ \hline
        \end{tabular}

\end{document}

enter image description here

If a thicker border is desired,

\documentclass[12pt]{article}

\usepackage{tikz}
\newcommand*\emptycirc[1][1ex]{\tikz\draw[thick] (0,0) circle (#1);} 
\newcommand*\halfcirc[1][1ex]{%
  \begin{tikzpicture}
  \draw[fill] (0,0)-- (90:#1) arc (90:270:#1) -- cycle ;
  \draw[thick] (0,0) circle (#1);
  \end{tikzpicture}}
\newcommand*\fullcirc[1][1ex]{\tikz\fill (0,0) circle (#1);} 

\begin{document}

\begin{tabular}{|c|}
            \hline
            \emptycirc \emptycirc[2ex]\\ \hline
            \halfcirc \halfcirc[2ex]\\ \hline
            \fullcirc \fullcirc[2ex]\\ \hline
        \end{tabular}

\end{document}

enter image description here

3
  • You made it look classy! Thanks Steven May 3, 2019 at 14:48
  • cool! How would I make the half filled circle be filled on the right hand side (or top or bottom)? Jun 21, 2021 at 20:10
  • 1
    @FrederickNord Right fill: \draw[fill] (0,0)-- (-90:#1) arc (-90:90:#1) -- cycle ;, Top fill: \draw[fill] (0,0)-- (0:#1) arc (0:180:#1) -- cycle ;, Bottom fill: \draw[fill] (0,0)-- (180:#1) arc (180:360:#1) -- cycle ;. Jun 21, 2021 at 20:24
7

Run with xelatex or lualatex

\documentclass[12pt]{article}
\usepackage{array}
\usepackage{unicode-math}
\setmathfont{XITS Math}
\begin{document}

\begin{tabular}{|>{$}c<{$}>{\Huge$}c<{$}|}\hline
    \lgwhtcircle           &\lgwhtcircle\\ \hline
    \circlelefthalfblack   &\circlelefthalfblack\\ \hline
    \circlerighthalfblack  &\circlerighthalfblack\\ \hline
    \circlebottomhalfblack &\circlebottomhalfblack\\ \hline
       \circletophalfblack &\circletophalfblack\\ \hline
    \mdlgblkcircle         &\mdlgblkcircle\\ \hline
\end{tabular}

\end{document}

enter image description here

7

if you want circular nodes and not just circles, you could use following styles:

\documentclass[tikz, border=2mm]{standalone}
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}[
    fullcircle/.style={circle, draw=#1, fill=#1},
    fullcircle/.default=black,
    halfcircle/.style={circle, draw=#1, 
        path picture={\fill[#1] (path picture bounding box.north west) rectangle (path picture bounding box.south);}},
    halfcircle/.default=black,
    emptycircle/.style={circle, draw=#1, fill=none},
    emptycircle/.default=black,
    node distance=5mm
    ]

    \node[fullcircle] (a) {}; \node[fullcircle=red, minimum size=5ex, right=of a] (b) {};
    \node[halfcircle, below=of a] (a) {}; \node[halfcircle=red, minimum size=5ex, right=of a] (b) {};
    \node[emptycircle, below=of a] (a) {}; \node[emptycircle=red, minimum size=5ex, right=of a] (b) {};
    \end{tikzpicture}
    \end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .