[Tex/LaTex] Map marker symbol in TikZ (symbol with em and ex units doesn’t scale properly)

symbolstikz-pgf

Since there is no map marker symbol in the symbols list (at least I could not find it) I decided to draw it with TikZ. This is it:

\documentclass{article}
\usepackage{tikz}
    \newcommand{\point}{\tikz{
       \draw [rounded corners,blue, fill=blue](0,0) .. controls (-.05em,.2ex) and (-.3em,1.2ex) .. (0em,2.2ex) .. controls (.3em,1.2ex) and (.05em,.2ex) .. (0,0);
       \draw [blue,fill=white](0,1.15ex) circle (0.12em);}
}
\begin{document}
\tiny tiny \point text

\normalsize normal \point text

\Huge huge \point text
\end{document}

The problem is that it does not scale properly if I change the font size, for example {\Large text \point text}

problem with scaling

Do I need to draw a different symbol for each size I use or is there a way to let it scale properly?

Best Answer

The problem is the rounded corners part, which is not relative to the font size. So the solution is to set rounded corners=<x>ex, then it depends on the font size. The following example shows a solution an illustrated the problem with simple corners: \cornerI is rounded with the absolute same radius, while \cornerII is rounded with a radius proportional to the font size.

\documentclass{article}

\usepackage{tikz}

\newcommand{\point}{\tikz{
    \filldraw [rounded corners=0.6ex,blue] (0,0)
        .. controls (-.05em,.2ex) and (-.3em,1.2ex)
        .. (0em,2.2ex) .. controls (.3em,1.2ex) and (.05em,.2ex) .. (0,0);
    \draw [blue,fill=white](0,1.15ex) circle (0.12em);
}}

\newcommand{\cornerI}{\tikz{
    \draw [rounded corners] (0,0) -| (2ex,2ex);
}}
\newcommand{\cornerII}{\tikz{
    \draw [rounded corners=0.6ex] (0,0) -| (-2ex,2ex);
}}

\begin{document}
\tiny text \point\ text \cornerI\,\cornerII

\normalsize text \point\ text \cornerI\,\cornerII

\Huge text \point\ text \cornerI\,\cornerII
\end{document}

rounded corners


Furthermore it’s not a good idea to mix em and ex because they don’t scale the same way. Hav a look at the following example: The \Square is perfect for \Huge but not for smaller sizes.

squares

The reason is that the ratio 1em/1ex isn’t the same for all font sizes …

font size

… and it even depends on the font itself.

font family

\documentclass[fleqn]{article}
\usepackage{tikz,parskip}


\makeatletter
\newlength{\tmpa}
\newlength{\tmpb}
\newlength{\tmpc}
\newcommand{\EmExTest}[2][Computer Modern]{{%
   #2%
   \setlength{\tmpa}{1em}%
   \setlength{\tmpb}{1ex}%
   \pgfmathsetmacro\tmpc{\tmpb/\tmpa}%
   \normalsize#1 at \textbackslash\expandafter\@gobble\string#2:
   \[
      \frac{1\,\mathrm{ex}}{1\,\mathrm{em}}
      = \frac{\strip@pt\tmpb\,\mathrm{pt}}{\strip@pt\tmpa\,\mathrm{pt}}
      = \tmpc
   \]\par
}}
\makeatother

\newcommand{\Square}{\tikz{
    \fill (0,0) rectangle (10em,21.31ex);
}}

\begin{document}
\EmExTest{\tiny}
\EmExTest{\normalsize}
\EmExTest{\Huge}

\tiny \Square\quad
\normalsize \Square\quad
\Huge \Square

\EmExTest{\normalsize}% Computer Modern
\EmExTest[Palatino]{\normalsize\fontfamily{pxr}\selectfont}
\EmExTest[Helvetica]{\normalsize\fontfamily{phv}\selectfont}
\end{document}