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!

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

2 Answers 2

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}
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

3
  • 3
    Instead of 0.1, you can try .5ex. Commented Jun 2, 2023 at 11:46
  • @PaulGaborit indeed, looks much better and also allows scaling of the fonts, I didn't know ex or em could go in the coordinates, thank you for that!
    – JamesT
    Commented Jun 2, 2023 at 11:52
  • 3
    I wouldn't say that 0.5ex is hard coded as it will adjust with the fontsize so it is exactly what is asked for. Commented Jun 2, 2023 at 21:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .