Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.
share|improve this question
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 5: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
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 5:44
1  
@LoverofStructure You need textcomp for \textopenbullet. My full tex file is here. –  Xavier Feb 24 '13 at 2:07

1 Answer 1

up vote 10 down vote accepted

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).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.