Drawing a circle with numbers

798 views
Skip to first unread message

Galdratommi

unread,
Jan 28, 2012, 2:32:50 PM1/28/12
to LaTeX Users Group
Dear people

I want to draw a circle with 31 number (1-31) and to do two of these
numbers (nr. 8 and 18) with a color.
I can do the circle but am having problem in finding some solutions on
the Internet for the other part.

\begin{tikzpicture}
\draw[thin](0,0) circle (5cm);
\end{tikzpicture}

I found this: pin=[<options>]<angle>:{text} but coukd not find any
examples with it.

Any ideas?

thanks
Tomas

Marina Vasques

unread,
Jan 28, 2012, 3:19:18 PM1/28/12
to latexus...@googlegroups.com
You should check this out:

http://tex.stackexchange.com/questions/7032/good-way-to-make-textcircled-numbers

I used one of their solutions and added the color (red) to one of the
numbers. It may not be a very elegant solution (since you have to type
all the numbers, which is ok for 31 numbers but very inconvenient for
a larger interval), but I think it works for you.

Remember to declare the color package, you can read more about it at:

http://en.wikibooks.org/wiki/LaTeX/Colors

So, for 3 numbers only:

\documentclass{article}
\usepackage{tikz}
\usepackage{color}


\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
\node[shape=circle,draw, inner sep=2pt] (char) {#1};}}
\begin{document}
\circled{1} \circled{\textcolor{red}{2}} \circled{3}

\end{document}

Peter Flynn

unread,
Jan 28, 2012, 3:21:12 PM1/28/12
to latexus...@googlegroups.com

No need for tikz unless you want to control the thickness of the circle.

\documentclass{article}
\usepackage[svgnames]{xcolor}
\def\circle{\raisebox{-.25ex}{\LARGE$\bigcirc$}}
\newcommand{\ring}[2][\relax]{%
  \ooalign{\hidewidth\if#1\relax
    \else\color{#1}\fi#2\hidewidth\crcr\circle}}

\begin{document}
\ring{1}\dots\ring{2}\dots\ring{3}\dots
\ring[CornflowerBlue]{8}\dots
\ring{9}\dots
\ring{10}\dots\ring{11}\dots\ring[Purple]{18}\dots
\ring{31}

\end{document}

This works for a document fonrsize of 10pt; you'll need to adjust the size of the \circle and the amount of the \raisebox for other type sizes.

///Peter

Marina Vasques

unread,
Jan 28, 2012, 3:35:12 PM1/28/12
to latexus...@googlegroups.com
CornflowerBlue is a beautiful color... but I wonder why they made 68
standard color (http://en.wikibooks.org/wiki/LaTeX/Colors), I can't
see 68 different colors there. Many of them look the same to me. It
creeps me out.

Galdratommi

unread,
Jan 28, 2012, 3:37:19 PM1/28/12
to LaTeX Users Group
Hi

I think I should explain this better, I want the circle it self to
have numbers like a clock but with 31 number instead of 12 which are
on the clock and two of these 31 to be in a colour.



On Jan 28, 8:21 pm, Peter Flynn <anglebrac...@gmail.com> wrote:

Peter Flynn

unread,
Jan 28, 2012, 4:02:00 PM1/28/12
to latexus...@googlegroups.com
On Sat, Jan 28, 2012 at 8:35 PM, Marina Vasques <marina....@gmail.com> wrote:
CornflowerBlue is a beautiful color... but I wonder why they made 68
standard color (http://en.wikibooks.org/wiki/LaTeX/Colors), I can't
see 68 different colors there.

I can: 4 columns of 17 colours makes 68. That's the dvipsnames range. The names and shades correspond to the colours in the large box of Crayola pencils, which used to be on every artist's desk, so the names would have been instantly familiar to them.

The svgnames range is the 256 shades defined in the SVG spec, and so will be more familiar to software developers.
 
Many of them look the same to me. It creeps me out.

Don't view them in a web browser: most browsers use a defective colour model whose gamut is limited to the "web-safe" colours (it shouldn't be necessary these days, but screens have very poor colour resolution), so what you see is NOT what you get. Print or view the colours in the xcolor package documentation instead.

///Peter

Peter Flynn

unread,
Jan 28, 2012, 4:02:57 PM1/28/12
to latexus...@googlegroups.com
On Sat, Jan 28, 2012 at 8:19 PM, Marina Vasques <marina....@gmail.com> wrote:
[...]

Remember to declare the color package,

Please don't. It's obsolete for many years. Use xcolor instead.

///Peter

Peter Flynn

unread,
Jan 28, 2012, 4:05:21 PM1/28/12
to latexus...@googlegroups.com
On Sat, Jan 28, 2012 at 8:37 PM, Galdratommi <galdr...@googlemail.com> wrote:
Hi

I think I should explain this better, I want the circle it self to
have numbers like a clock but with 31 number instead of 12 which are
on the clock and two of these 31 to be in a colour.

Ah. That's very different. So the numbers will be at 12° intervals (360 div 30)?
Yes, tikz or Lua would be a good choice. Not my forte.

///Peter

Gildas Cotomale

unread,
Jan 28, 2012, 5:29:43 PM1/28/12
to latexus...@googlegroups.com
2012/1/28 Peter Flynn :

> On Sat, Jan 28, 2012 at 8:35 PM, Marina Vasques <marina....@gmail.com>
> wrote:
>>
>> CornflowerBlue is a beautiful color... but I wonder why they made 68
>> standard color (http://en.wikibooks.org/wiki/LaTeX/Colors), I can't
>> see 68 different colors there.
>
Sometimes i can, sometimes i can't. It depends of the browser and the
operating system and it's calibration and the ambiant light...
A white background and filled boxes (instead of characters) are more
readable <http://tex.loria.fr/graph-pack/grf/gr2.htm>

>
> I can: 4 columns of 17 colours makes 68. That's the dvipsnames range. The
> names and shades correspond to the colours in the large box of Crayola
> pencils, which used to be on every artist's desk, so the names would have
> been instantly familiar to them.
>
Yes ^^ According to an uncle of mine they were 64 then 72... (4
columns of 18) :/ And Wikipedia says that around 133 names have been
around <http://en.wikipedia.org/wiki/List_of_Crayola_crayon_colors>
Crayola own site says that there are 120 colours now
<http://www.crayola.com/colorcensus/history/index.cfm>
<http://www.crayola.com/colorcensus/history/current_120_colors.cfm>
The 68 kept here are the first and most common in time.

> The svgnames range is the 256 shades defined in the SVG spec, and so will be
> more familiar to software developers.
>

147... <http://www.december.com/html/spec/colorsvg.html>
They are also known as Netscape colours' names
<http://webdesign.about.com/od/colorcharts/l/bl_namedcolors.htm>
In fact they come from X11... (with some minor differences with sRGB)
<http://en.wikipedia.org/wiki/Web_colors#X11_color_names>

>>
>> Many of them look the same to me. It creeps me out.
>
>
> Don't view them in a web browser: most browsers use a defective colour model
> whose gamut is limited to the "web-safe" colours (it shouldn't be necessary
> these days, but screens have very poor colour resolution), so what you see
> is NOT what you get. Print or view the colours in the xcolor package
> documentation instead.
>

PS to read/print (use a good screen/printer-resolution to look)
http://www.math.harvard.edu/computing/latex/color.html

The 216 web-safe colours <http://html-color-codes.com/> are "safe" as
a common denominator for 256-colours dsplays and high-possible : they
should be rendered very similary to X11-colours or lower bits
resolution colours (do you remember those 16 or 32 colours we were
happy to produce old days?)
<http://en.wikipedia.org/wiki/Web_colors#HTML_color_names> and others
<http://www.graphviz.org/doc/info/colors.html#brewer>


p.s: if you can read french, have a look at
<http://fr.wikibooks.org/wiki/R%C3%A9daction_technique/De_l%27usage_des_couleurs_dans_un_document>

Marina Vasques

unread,
Jan 28, 2012, 7:11:55 PM1/28/12
to latexus...@googlegroups.com
31 numbers inside a circle! I modified an example of an analog clock
(http://www.latex-community.org/forum/viewtopic.php?f=5&t=6320).
Numbers 8 and 18 are in a different color. You can change the color,
the radius of the circle, the scale of the numbers, the position of
the numbers relatively to the border of the circle. I had to use 5
different \foreach because of the colors... again: not elegant, but
functional.


\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{xcolor}
\begin{document}

\begin{centering}

% Define a few constants for easy configuration
\def\radius{4cm}
\def\labelrad{3.8cm}

\begin{tikzpicture}[scale=1]
% adding a subtle gray tone to add a bit of "personality"
\shade[shading=radial, inner color=white, outer color=gray!15] (0,0)
circle (\radius);

\draw (0,0) circle (\radius);

\foreach \x in {1,...,7}
\node[scale=0.5] (\x) at (360-11.6129032*\x+90:\labelrad) {\x};

\foreach \x in {8}
\node[scale=0.5, color=red] (\x) at (360-11.6129032*\x+90:\labelrad) {\x};

\foreach \x in {9, 10, ..., 17}
\node[scale=0.5] (\x) at (360-11.6129032*\x+90:\labelrad) {\x};


\foreach \x in {18}
\node[scale=0.5, color=red] (\x) at (360-11.6129032*\x+90:\labelrad) {\x};


\foreach \x in {19, 20, ..., 31}
\node[scale=0.5] (\x) at (360-11.6129032*\x+90:\labelrad) {\x};


\end{tikzpicture}
\end{centering}

\end{document}

Marina Vasques

unread,
Jan 28, 2012, 8:53:07 PM1/28/12
to latexus...@googlegroups.com
But I still don't get the colors! :)

Galdratommi

unread,
Jan 29, 2012, 8:14:39 AM1/29/12
to LaTeX Users Group
Thanks

This is exactly what I wanted :-)

best wishes
Tómas

rahul kumar

unread,
Sep 18, 2018, 2:58:02 AM9/18/18
to LaTeX Users Group
try this one...html color code
Reply all
Reply to author
Forward
0 new messages