4

My MWE:

\documentclass{scrreprt}
\usepackage{tikz}

\begin{document} Text \tikz\filldraw [lightgray,radius = 1pt] (0,0) circle[anchor = north]; more Text \tikz\filldraw [black,radius = 1pt] (0,0) circle[anchor = north]; more Text. \end{document}

produces the following result

result

As you can see the circles are on the baseline of the text line.

How can one vertically center the circles within the text line? Vertically center is meant if one would draw a virtual line through the vertical center of the small letters, excluded letters with ''non standard'' height: f,g,h,i,j,k,l,p,q,t,y.

Thank you for your help and effort in advance!

Su-47
  • 2,508
  • 1
    It depends on what you mean by "centered"... with respect to the "t" or the "m"? (or the base line skip, or...) – Rmano Jun 02 '23 at 10:29
  • Hello @Rmano. Thank you for your comment! See the edited question. – Su-47 Jun 02 '23 at 11:20

2 Answers2

6

You can enclose the tikzpicture in \vcenter{\hbox{...}} to avoid manual adjustments.

enter image description here

\documentclass{scrreprt}
\usepackage{tikz}

\begin{document} Text $\vcenter{\hbox{\tikz\filldraw [lightgray,radius = 1pt] (0,0) circle[anchor = north];}}$ more Text $\vcenter{\hbox{\tikz\filldraw [black,radius = 1pt] (0,0) circle[anchor = north];}}$ more Text. \end{document}

Sandy G
  • 42,558
4

This is one possible way using y = 0.5ex which scales with different fonts:

enter image description here

\documentclass{scrreprt}
\usepackage{tikz}

\begin{document} \noindent Text \tikz[baseline]\filldraw [lightgray,radius = 1pt] (0,0.5ex) circle; more Text \tikz[baseline]\filldraw [black,radius = 1pt] (0,0.5ex) circle; more Text. \end{document}


You could even create a command to simplify things further in-text:

\documentclass{scrreprt}
\usepackage{tikz}

\NewDocumentCommand{\MidDot}{O{black} O{1}}{% \tikz[baseline]\filldraw [#1, radius=#2pt] (0,0.5ex) circle;% }

\begin{document} \noindent Text \tikz[baseline]\filldraw [lightgray,radius = 1pt] (0,0.5ex) circle; more Text \tikz[baseline]\filldraw [black,radius = 1pt] (0,0.5ex) circle; more Text.\ Text \MidDot[lightgray] more Text \MidDot
more Text. \end{document}

which produces:

enter image description here

JamesT
  • 3,169