# circled letters: same size as uncircled letters

I use this macro to circle letters:

\newcommand*\crc[1]{%
\begin{tikzpicture}[baseline=(C.base)]
\node[draw=red,dashed,circle,inner sep=0pt, minimum size=0.5cm](C) {#1};
\end{tikzpicture}}


I want to circle a letter, but I do not want it to change its size. As you can see in the picture, it makes a huge difference if a letter is circled or not:

For reference, this is the code for the above tables:

\begin{tabular}{|c|c|c|}
\hline
ts2 & y / Y       & n / N \\
nu3 & n / \crc{N} & n / N \\ \hline
\end{tabular}


(The first table only has an "N" instead of "\crc{N}".)

What I want is that the circle does not count into the size of the letter, so that the table stays the same size as the first one. It is ok if the circle touches or goes through other letters or table borders.

Any ideas? I am open to other solutions of circling the letter, but I want to be able to compile with pdflatex.

• \smash the sucker! (You might also \vphantom the original.) – John Kormylo Sep 15 '15 at 14:40

Add another node to draw the border with overlay option.

\documentclass{article}
\usepackage{tikz}
\newcommand*\crc[1]{%
\begin{tikzpicture}[baseline=(C.base)]
\node[inner sep=0pt](C) {#1};
\node[draw=red,dashed,circle,inner sep=0pt, minimum size=0.4cm,overlay]at (C.center) {\phantom{#1}};
\end{tikzpicture}}
\begin{document}
\begin{tabular}{|c|c|c|}
\hline
ts2 & y / Y       & n / N \\
nu3 & n / \crc{N} & n / N \\ \hline
\end{tabular}
\begin{tabular}{|c|c|c|}
\hline
ts2 & y / Y       & n / N \\
nu3 & n / N & n / N \\ \hline
\end{tabular}
\end{document}


• I didn't know about the existence of overlay. Thanks, this really helps (not only in this particular problem)! – Kjara Sep 15 '15 at 14:54

You may also be interested in the spot package, which applies TikZ node options to text without disturbing the spacing. It was written to highlight words in Beamer slides, but it also works in the article class.

\documentclass{article}
\usepackage{spot}
\begin{document}

\newcommand*\crc[1]{%

\begin{tabular}{|c|c|c|}
\hline
ts2 & y / Y       & n / N \\
nu3 & n / \crc{N} & n / N \\ \hline
\end{tabular}
\begin{tabular}{|c|c|c|}
\hline
ts2 & y / Y       & n / N \\
nu3 & n / N       & n / N \\ \hline
\end{tabular}
\dospots
\end{document}


The inner workings of spot take care of the overlay option, matching up the baseline, etc. automatically. The chief downside is that in certain circumstances (such as this one, inside a tabular environment when not using Beamer) you sometimes have to manually issue a \dospots command later on the page. The advantages are that you don't need to remember the code about baselines and overlays yourself, you can use any node options including fills, you can name the node for using in a later TikZ overlay, and the circle or other decoration will not be covered up by later text. Here's an illustration:

\documentclass{article}
\usepackage{spot}
\begin{document}

\newcommand*\circleit[1]{%
\begin{tikzpicture}[baseline=(C.base)]
\node[inner sep=0pt](C) {\phantom{#1}};
\node[draw=red,fill=yellow,circle,minimum size=0.4cm,overlay]at (C.center) {{#1}};
\end{tikzpicture}}

ABC\circleit{DEF}GHI
ABC\circlespot{DEF}GHI
\bigskip

ABC\spot(mynode){DEF}GHI

\begin{tikzpicture}[overlay, remember picture]
\draw[<-] (mynode) -- ++(1,-0.5) node[anchor=west] {Here is my node.};
\end{tikzpicture}

\end{document}


If you look carefully, you'll see that the code \circleit leaves the G overlapping both the yellow fill and the red drawn circle, whereas the spot version typesets the DEF, circle, and fill above both the preceding C and the following G. The third instance shows both the default values of spot (intended for highlighting words in Beamer presentations) and its ability to name the node for later use.

All this is probably overkill for your scenario, though.

• Yes, absolute overkill! :) Thanks anyway, I might use this spot package sooner or later. Didn't know about it either. – Kjara Sep 22 '15 at 21:11