I am trying to highlight some parts of a document by setting them inside boxes drawn with TikZ. In order to retain a readable document, I do so with a simple macro, \focus:
\documentclass{article}
\usepackage{tikz}
\begin{document}
% highlighting
\newcommand*{\focus}[1]{%
\tikz[baseline]\node[rectangle, inner ysep=0pt, inner xsep=2pt, anchor=text, fill=lightgray, anchor=base]{$#1$};%
}
\focus{x} \focus{g}
\end{document}
As you can see, the highlighting works in general, but the size of the drawn rectangle is determined by the size of the enclosed characters. Is there any way to obtain a uniform size for a whole line?


\newcommand*{\focus}[1]{% \tikz[baseline]\node[rectangle, inner ysep=0pt, inner xsep=2pt, anchor=text, fill=lightgray, anchor=base]{\strut$#1$};% }. Related/duplicate: http://tex.stackexchange.com/questions/133227/how-to-align-text-in-tikz-nodes-by-baseline and http://tex.stackexchange.com/questions/301432/align-tikz-word-overlays – Steven B. Segletes Oct 31 '16 at 15:16