20

How can I draw oval circle around a string? For example, when I have "1,3,4,6", how can I put them in a circle?

enter image description here

prosseek
  • 6,033

5 Answers5

16

I found this code works fine with me.

\usetikzlibrary{arrows}
\usetikzlibrary{shapes}
\newcommand{\mymk}[1]{%
  \tikz[baseline=(char.base)]\node[anchor=south west, draw,rectangle, rounded corners, inner sep=2pt, minimum size=7mm,
    text height=2mm](char){\ensuremath{#1}} ;}

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

Hello, \mymk{1,2,3,4,5} world \circled{1}

enter image description here

Refer to How to draw a circle around text and Good way to make \textcircled numbers?.

prosseek
  • 6,033
  • it'd be great if you could reference your source – cmhughes Aug 20 '13 at 03:44
  • @cmhughes: updated my answer. – prosseek Aug 20 '13 at 04:01
  • You can control the "roundedness" of the corners by passing values to rounded corners. For example, rounded corners=10pt would produce a shape more closely resembling the one in your question. – Herr K. Aug 20 '13 at 05:39
  • Using DeclareRobustCommand instead of newcommand was necessary for me to make it work with some bibtex / backref commands. – Watson Jan 12 '21 at 08:08
16

The shapes.misc library offers the rounded rectangle shape. You can also use the shadows library to add shadows.

\documentclass[border=3pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{shapes.misc,shadows}

\begin{document}

\begin{tikzpicture}[baseline=(char.base)]
\node(char)[draw,fill=white,
  shape=rounded rectangle,
  drop shadow={opacity=.5,shadow xshift=0pt},
  minimum width=1.8cm]
  {1,3,4,6};
\end{tikzpicture}

\end{document}

enter image description here

Herr K.
  • 17,946
  • 4
  • 61
  • 118
5

Just for comparison, here is a ConTeXt solution:

\defineframed
    [roundframed]
    [
      corner=round,
      location=low,
      loffset=0.1em,
      roffset=0.1em,
    ]

\starttext

Hello \roundframed{1,2,3,4} world.

\stoptext

which gives

enter image description here

Aditya
  • 62,301
4

Sorry, I don't have the ability to add comments on the TeX site yet. You can look at the thread dustin mentioned. Alternatively, you can use a box: $\boxed{1,3,4,6}$, which will appear:

enter image description here

dustin
  • 18,617
  • 23
  • 99
  • 204
Ahaan S. Rungta
  • 448
  • 1
  • 4
  • 16
3

Here is one solution using tcolorbox...

   \documentclass{article}
     \usepackage[most]{tcolorbox}

    \begin{document}
    \tcbox[enhanced,drop shadow,colback=white]{\Large 1,2,3,4}
    \end{document}

The out put is.. enter image description here

David
  • 1,964