4

I would like to generate a symbol that is tipa's \textlengthmark with a small circle overlaid perfectly in the middle, so that the symbol has vertical and horizontal symmetry.

How do I do this? (I have a suspicion that tikz will help, but I am not sure whether this machinery is really needed.)

Some clarifications:

  • The symbol should scale to arbitrary sizes. (I am using anyfontsize.)
  • The circle should be small, that is I don't want \text{\textcircled{\(\Utextlengthmark\)}} (with an enclosing circle).
  • There are a couple of similar questions here, but the point is that I don't want to have to manually adjust the vertical alignment. There should be a way of having TeX automatically match their horizontal and vertical centers. Also, if I use a manual shift amount for a \raisebox, that's not gonna work in a subscript context etc. (I never figured out how to get manually scaled and shifted symbols to automatically "work" in subscripts.)

The following code (adapted from here)

\documentclass{memoir}
\usepackage[T3,T1]{fontenc}
\usepackage[noenc,safe]{tipa}

\def\typeC{\mathrel{%
    \mathchoice{\TYPEC}{\TYPEC}{\scriptsize\TYPEC}{\tiny\TYPEC}%
}}
\def\TYPEC{{%
    \setbox0\hbox{\textlengthmark}%
    \rlap{\hbox to \wd0{\hss\(\circ\)\hss}}\box0
}}

\begin{document}

\(\typeC + S_{\typeC}\)

\end{document}

has two problems:

  • The \circ is too large; about half the size would be desired.
  • The \circ is not vertically centered.
  • 2
    Did you already tried the general questions about math symbols: How to look up a symbol? and Overlay symbol with another? – Martin Scharrer Feb 22 '13 at 05:58
  • @MartinScharrer Yes, very much exhaustively. | Yes; see my edit. – Lover of Structure Feb 22 '13 at 15:35
  • @MartinScharrer There are two things to keep in mind: 1. If I do a manual \raisebox-adjustment, that in my experience does not scale right (in a subscript, footnote, ... context). 2. It should be possible to have the centering be performed automatically. What's more, both symbols have perfect horizontal and vertical symmetry. – Lover of Structure Feb 22 '13 at 16:16
  • @LoverofStructure The raisebox is not an issue if you use fontsize-dependent lengths, i.e. em or ex. The only issue is the scaling. I tried with the relsize package, but get stuck on very small sizes (incl. sub- and superscripts). FYI, here is my code: \renewcommand{\RSsmallest}{1pt} and \def\TYPEC{{\setbox0\hbox{\textlengthmark}\rlap{\hbox to \wd0{\hss\raisebox{0.11ex{\smaller[2]\textopenbullet}\hss}}\box0}} – Xavier Feb 22 '13 at 21:33
  • @Xavier I often scale with \scalefont for precise results, and I simply haven't figured out how to adapt such scaling for superscripts etc automatically. – Lover of Structure Feb 22 '13 at 23:36
  • @Xavier I was trying out your code, but my system doesn't know \RSsmallest. How can I make it work/compile? – Lover of Structure Feb 22 '13 at 23:40
  • You need to load the relsize package. But Heiko's answer below seems to work perfectly. – Xavier Feb 22 '13 at 23:53
  • @Xavier I tried it with relsize, but it doesn't compile. I think something about the parentheses in your posted code doesn't match up. Could you check again? Also it might be worth an answer, despite Heiko already having posted one. – Lover of Structure Feb 22 '13 at 23:59
  • @LoverofStructure There was indeed a closing brace missing after the 0.11ex :( I've posted the code and result here. I don't think it's worth an answer, as it doesn't work for small size as I wrote earlier – Xavier Feb 23 '13 at 01:00
  • @Xavier Could you post your correction in a comment here? Also, it's okay on TeX.SE if an answer merely adds additional information (even though it's unlikely to be accepted as the chosen/right answer), so posting it as an answer is fine (and will get my upvote). – Lover of Structure Feb 23 '13 at 01:04
  • 1
    @LoverofStructure Sure, here it is: \def\TYPEC{{\setbox0\hbox{\textlengthmark}\rlap{\hbox to \wd0{\hss\raisebox{0.11ex}{\smaller[2]\textopenbullet}\hss}}\box0}} – Xavier Feb 23 '13 at 05:44
  • @Xavier
    This \documentclass{memoir} \usepackage[T3,T1]{fontenc} \usepackage[noenc,safe]{tipa} \usepackage{relsize} \renewcommand{\RSsmallest}{1pt} \def\typeC{\mathrel{\mathchoice{\TYPEC}{\TYPEC}{\scriptsize\TYPEC}{\tiny\TYPEC}}‌​} \def\TYPEC{{\setbox0\hbox{\textlengthmark}\rlap{\hbox to \wd0{\hss\raisebox{0.11ex}{\smaller[2]\textopenbullet}\hss}}\box0}} \begin{document} \(\typeC + S_{\typeC}\) \end{document} still doesn't compile ...
    – Lover of Structure Feb 23 '13 at 22:09
  • 1
    @LoverofStructure You need textcomp for \textopenbullet. My full tex file is here. – Xavier Feb 24 '13 at 02:07
  • @Xavier Great! It looks like adding textcomp to my code does the trick; calc (from your source code) is not needed, though. – Lover of Structure Feb 24 '13 at 02:20
  • @LoverofStructure No indeed. I originally used calc to calculate the raise offset as 0.5\height-0.5\ht0, which didn't give perfect results for some reason I don't get... – Xavier Feb 24 '13 at 03:52
  • @LoverofStructure Well, Heiko just found out why. I checked the depth of the elements, but didn't suspect a wrong bounding box and learned something new. This long chat finally paid off :D – Xavier Feb 24 '13 at 03:56

1 Answers1

11

The following solution constructs the symbol from \textlengthmark and \circ. The latter symbol \circ is vertically centered to the current math axis. First the middle of \circ is moved to the base line, then it is scaled down to 28 percent of the height of \textlengthmark. Then the resized circle is moved to the middle of \textlengthmark. \text is needed for resizing the text symbol \textlengthmark according to the current math style. \mathpalette is used to construct the symbol for the current math style:

\documentclass{article}
\usepackage{tipa}
\usepackage{amstext}% or amsmath
\usepackage{graphicx}% or graphics

\makeatletter \newcommand{\circlengthmark}{% {\CircLengthMarkAux}% % curly braces allow the use of the symbol after ^ or _ without braces } \DeclareRobustCommand{\CircLengthMarkAux}{% \ensuremath{% \mathpalette@CircLengthMarkAux{\text{\textlengthmark}}% }% } \newsavebox\clm@boxa \newsavebox\clm@boxb \newcommand*{@CircLengthMarkAux}[2]{% % #1 contains one of \displaystyle, \textstyle, % \scriptstyle or \scriptscriptstyle % #2 contains the length mark symbol \sbox\clm@boxa{$\m@th#1#2$}% \textlengthmark \sbox\clm@boxb{$#1\vcenter{}$}% math axis \hbox to 0pt{% \kern.5\wd\clm@boxa \hss \raise.5\ht\clm@boxa\hbox{% \resizebox{!}{.14\ht\clm@boxa}{% adopt the factor to your needs \lower\ht\clm@boxb\hbox{$\m@th#1\circ$}% }% }% \hss \kern-.5\wd\clm@boxa }% \usebox\clm@boxa } \makeatother

\begin{document} Symbol: \circlengthmark (\textlengthmark) $\circlengthmark^{\circlengthmark^\circlengthmark}$ \end{document}

Result

Update: More perfection

With higher magnification values the circle is not perfectly centered, it is a tiny bit too low. The reason is the character bounding box of \textlengthmark. Its upper and lower bounds are too small by asymmetric amounts:

\documentclass[border=.1pt]{standalone}
\usepackage{tipa}
\usepackage{xcolor}
\setlength{\fboxsep}{0pt}
\setlength{\fboxrule}{0.02pt}
\begin{document}
\fbox{\color{red}\textlengthmark}%
\fbox{\textcolor{red}{\raisebox{0pt}[1.025\height][0.02\height]{\textlengthmark}}}%
\fbox{\color{red}$\circ$}
\end{document}

Char boxes

The middle symbol compensates by enlarging the height and depth.

\documentclass[border=.1pt]{standalone}
\usepackage{tipa}
\usepackage{amstext}
\usepackage{graphicx}

\makeatletter \newcommand{\circlengthmark}{% {\CircLengthMarkAux}% % curly braces allow the use of the symbol after ^ or _ without braces } \DeclareRobustCommand{\CircLengthMarkAux}{% \ensuremath{% \mathpalette@CircLengthMarkAux{\text{\textlengthmark}}% }% } \newsavebox\clm@boxa \newsavebox\clm@boxb \newcommand*{@CircLengthMarkAux}[2]{% % #1 contains one of \displaystyle, \textstyle, % \scriptstyle or \scriptscriptstyle % #2 contains the length mark symbol \sbox\clm@boxa{% % \textlengthmark with fix of character bounding box \raisebox{0pt}[1.025\height][.02\height]{% $\m@th#1#2$% }% }% \sbox\clm@boxb{$#1\vcenter{}$}% math axis \hbox to 0pt{% \kern.5\wd\clm@boxa \hss \dimen@=.5\ht\clm@boxa \advance\dimen@ by -.5\dp\clm@boxa \raise\dimen@\hbox{% \resizebox{!}{.14\ht\clm@boxa}{% adopt the factor to your needs \lower\ht\clm@boxb\hbox{$\m@th#1\circ$}% }% }% \hss \kern-.5\wd\clm@boxa }% \usebox\clm@boxa } \makeatother

% for testing \usepackage{xcolor} \setlength{\fboxsep}{0pt} \setlength{\fboxrule}{0.02pt}

\begin{document} \fbox{\color{red}\circlengthmark}% \textsuperscript{\fbox{\color{red}\circlengthmark}} \end{document}

Result with fix of character bounding box

For greater perfection, both \textlengthmark and the circled symbol need to be replaced by a better font or drawn from scratch (e.g. tikz).

Heiko Oberdiek
  • 271,626