8

Given this simple scenario:

\documentclass{article}
\usepackage{tikz}
\newcommand\encircle[1]{%
\tikz[baseline=(X.base)] 
   \node (X) [draw, shape=circle, inner sep=0] {\strut #1};}
\begin{document}
\section{Introduction}
\encircle{A}
\end{document}

The output is this: enter image description here

How do I change it so that the circle has a black background and the color of the text inside the circle is white (basically, reversing the colors) ?

2 Answers 2

9

Use the fill key to set the background colour and the text key to set the text colour; in your application this means fill=black, text=white.

\documentclass[border=1mm]{standalone}
\usepackage{tikz}
\newcommand\encircle[1]{%
  \tikz[baseline=(X.base)] 
    \node (X) [draw, shape=circle, inner sep=0, fill=black, text=white] {\strut #1};%
}
\begin{document}
\encircle{A}
\end{document}

enter image description here

1

To deal with any errors do:

\DeclareRobustCommand\encircle[1]{\tikz[baseline=(char.base)]{\node[shape=circle,fill,inner sep=2pt] (char) {\textcolor{white}{#1}}}}

TikZ: non-active semi-colon

You must log in to answer this question.

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