1

This was a very good starting point for the solution below, which is still not perfect for my usecase.

I've tried to adapt it to show 3 circled letters with zero or more intervening letter between the circled ones and zero or more letters right out of the first and third circle. In other words, the desired scheme is that I want to type xOxOxOx, where each O represents a single circled possibly different letter, and each x represents a sequence of zero or more letters. The desired result is something like this (the code is below):

enter image description here

What I don't like of this solution is that I had to hardcode a 1.3 multiplicative factor for \f@size. Indeed, if I remove *1.3, the size of the circle around m will be bigger than that of the circles around i and j. The 1.6 in the linked answer seemed a bit too much.

Here's the MWE verified on David Carlisle's TeXlive.net:

\documentclass{article}
\usepackage{tikz}

\begin{document}
\makeatletter
\newcommand\stencil[7]{%
\tikz[outer sep=0, inner sep=0, baseline=(A.base), anchor=west]{
  \node (A) {\vphantom{Wpm}#1};
  \node[shape=circle, draw, minimum height={\f@size*1.3}] (B) at (A.east) {\vphantom{Wpm}#2};
  \node (C) at (B.east) {\vphantom{Wpm}#3};
  \node[shape=circle, draw, minimum height={\f@size*1.3}] (D) at (C.east) {\vphantom{Wpm}#4};
  \node (E) at (D.east) {\vphantom{Wpm}#5};
  \node[shape=circle, draw, minimum height={\f@size*1.3}] (F) at (E.east) {\vphantom{Wpm}#6};
  \node (G) at (F.east) {\vphantom{Wpm}#7};
}%
}
\makeatother

before\stencil{h}{i}{j}{k}{}{m}{}after

beforeh

before \stencil{h}{i}{j}{k}{}{m}{} after

before h

\end{document}
1
  • Why don't you like hardcoding the multiplicative factor? If it is the same always then you don't have to manually adjust it for new inputs. It makes sense to set a minimum size for the circle that is somewhat bigger than the font size, otherwise the content of the letter+padding will be bigger than the minimum size in some cases which causes the content to determine the size instead of the minimum that you specified.
    – Marijn
    Jan 22 at 18:22

4 Answers 4

6

With text height={height("W")}, text depth={depth("p")}, and text width={width("m")}, you can set the height, depth, and width of your node text with the same height of W, the same depth of p and the same width of m:

\documentclass{article}
\usepackage{tikz}
\tikzset{
    mystyle/.style={ 
        text centered,
        text height={height("W")}, 
        text depth={depth("p")}
        },
    mycircle/.style={
        mystyle,
        shape=circle, draw,
        text width={width("m")} 
        }
    }

\newcommand\mystencil[7]{%
    \tikz[outer sep=0, inner sep=0, baseline=(A.base), anchor=west]{
      \node[mystyle] (A) {#1};
      \node[mycircle] (B) at (A.east) {#2};
      \node[mystyle] (C) at (B.east) {#3};
      \node[mycircle] (D) at (C.east) {#4};
      \node[mystyle] (E) at (D.east) {#5};
      \node[mycircle] (F) at (E.east) {#6};
      \node[mystyle] (G) at (F.east) {#7};
}%
}

\begin{document}

before\mystencil{h}{i}{j}{k}{}{m}{}after

beforeh

before \mystencil{h}{i}{j}{k}{}{m}{} after

before h

\end{document}

enter image description here

2

Perhaps I'm misunderstanding the problem here, but a macro to circle a single inline letter could be easier, either by setting a \vphantom as in your example, or setting the text depth, text height and minimum size as in the code below:

enter image description here

\documentclass{article}

\usepackage{tikz}
\newcommand{\C}[1]{\tikz[baseline=(A.base)]{\node[draw, circle, minimum size=3ex, text depth=.5ex, text height=1.8ex, inner sep=0pt](A){#1};}}

\begin{document}

h \C{m}j\C{i}\C{j}\C{k} a

\end{document}
2

Unicode has an Enclosed Alphanumerics codeblock, so you could use direct input with a suitable font, like Noto Sans Symbols, or a CJK font:

enclosed

Note that, here, the circle is the starting point, and the letter is made to fit, like on a typewriter, leaving line-spacing undisturbed.

MWE

\documentclass{article}

\usepackage{fontspec}
\newfontface{\cc}{Noto Sans Symbols}
\newfontface{\dd}{Noto Serif CJK JP}

\begin{document}

Examples

before {\cc hⓘjⓚlⓜ} after

{\cc before hⓘjⓚlⓜ after ⓗⓘⓙⓚⓛⓜ}


before {\dd hⓘjⓚlⓜ} after

{\dd before hⓘjⓚlⓜ after ⓗⓘⓙⓚⓛⓜ}


\end{document}
2

You don't need TikZ for declaring your \stencil macro. The \enclosecircle is declared in Unicode math.

\newbox\circlebox
\setbox\circlebox=\hbox to1.1em{\hss$\phantom x\enclosecircle$\hss}
\def\ecirc#1{\leavevmode\rlap{\hbox to1.1em{\hss#1\hss}}\copy\circlebox}

\def\stencil#1#2#3#4#5#6#7{#1\ecirc#2#3\ecirc#4#5\ecirc#6#7}

before\stencil{h}{i}{j}{k}{}{m}{}after

\bye

You must log in to answer this question.

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