TikZ-PGF – How to Create Circled Inline Numbers and Letters

circlestikz-pgf

Based on Good way to make \textcircled numbers?, is there a simple way to make the circles look exactly the same for numbers and all letters (i.e. size and placement)?

When one inserts an a in the circle, the node is drawn slightly lower than the node for a number.

\documentclass{article}

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

\begin{document}
This is \circled{a} \circled{1} balloon.
\end{document}

enter image description here

EDIT

Based on the answer by @koleygr and the post circled letters: same size as uncircled letters, I find this solution the most pleasing and versatile:

\newcommand*{\circled}[2][]{\tikz[baseline=(C.base)]{
    \node[inner sep=0pt] (C) {\vphantom{1g}#2};
    \node[draw, circle, inner sep=3pt, yshift=1pt] 
        at (C.center) {\vphantom{1g}};}}

enter image description here

Best Answer

Edit after accepted:

\documentclass{article}

\makeatletter
\usepackage{tikz}
\usetikzlibrary{calc}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
    \node[shape=circle, draw, inner sep=1pt, 
        minimum height={\f@size*1.6},] (char) {\vphantom{WAH1g}#1};}}
\makeatother

\begin{document}
This is \circled{a} \circled{1} balloon.

\noindent\foreach \letter in {A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,V,U,W,X,Y,Z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,1,2,3,4,5,6,7,8,9,0,.,/}
{%
\circled{\letter}\space%
}
\end{document}

Output:

enter image description here

Not really perfect because of different base on chars (but it is better from the bellow answer)

Checking the same code in the document environment above with below definition of circled:

enter image description here

As you can see with previous (below) code the sizes change between small and capital letters.

Old answer:

A \vphantom in your definition will help:

\documentclass{article}

\usepackage{tikz}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
    \node[shape=circle, draw, inner sep=1pt, 
        minimum height=12pt] (char) {\vphantom{1g}#1};}}

\begin{document}
This is \circled{a} \circled{1} balloon.
\end{document}

Output:

enter image description here