2

I'm doing something like this:

\documentclass{article}

\usepackage{tikz}

\newcommand{\ccor}[1]{% \tikz[remember picture]{% \nodefill=black!20,anchor=base{#1};% }% }

\begin{document} write some text with \ccor{color background}. \end{document}

and I'm just wondering if there is a way of lowering the picture a little so that the text is all aligned.

enter image description here

Concept7
  • 645

2 Answers2

3

I think the baseline option is better as follows --

\tikz[remember picture,
      baseline=(color.base)%<-----------------------added
     ]

enter image description here

\documentclass{article}

\usepackage{tikz}

\newcommand{\ccor}[1]{% \tikz[remember picture,baseline=(color.base)]{% \nodefill=black!20,anchor=base{#1};% }% }

\begin{document}

write some text with \ccor{color background}.

\end{document}

js bibra
  • 21,280
2

I've changed the command to:

\newcommand{\ccor}[1]{%
    \tikzmarknode{pos}{\vphantom{AA}}
    \tikz[remember picture,overlay]{%
        \node[fill=facebook!20,anchor=west](codigo)at (pos.west){\texttt{#1}};
        }
    \sbox0{\hphantom{#1}}
    \hspace{\wd0}
    }

and the result is satisfactory.

Concept7
  • 645