Drop shadow of baselined tikz node not placed correctly

I want to draw a tikz node that has as its baseline the baseline of the text around and have a drop shadow. My code however causes the drop shadow to be misplaced.

\documentclass[]{standalone}
\usepackage{tikz}

\newcommand{\propbox}[1]{
\hspace{-.125cm}\tikz[baseline=(A.base)]{\node[
fill = red,
}

\begin{document}
This is \propbox{some} sample text.
\end{document}


Compare this to the correct shadow, where the baseline for the node is not specified:

How can I fix the shadow?

Here is a temporary hack that you can use:

Note

• Are per Torbjørn T's suggestion, you can eliminate the \hspace{-.125cm} hack by inserting a % follwoing the open paren as that eliminates the suprious space that was being inserted.

Code:

\documentclass[border=5pt]{standalone}
\usepackage{tikz}

\newcommand{\propbox}[1]{%
%\hspace{-.125cm} <-- Hack fixed by % above
\tikz[baseline=(A.base)]{
\node[outer sep=1pt,
fill = red,
},
] (A) {#1};%
}% <--- NOTE. Without this you will have additional space following the \propbox'
}

\begin{document}
This is \propbox{some} sample text.
\end{document}


using tcolorbox

\documentclass[]{article}
\usepackage{tikz}

\usepackage{tcolorbox}
\tcbuselibrary{skins}

\newcommand{\propbox}[1]{
\hspace{-.125cm}\tikz[baseline=(A.base)]{\node[
fill = red,
}

\begin{document}

This is \propbox{some} sample text.

This is \tcbox[enhanced, size=fbox, drop fuzzy shadow=black,
nobeforeafter, boxsep=2pt, coltext=white, frame hidden, on line,
colback=red!75,]{some} sample text

\end{document}
`

• Thanks, but is there a solution with tikz? This was just a minimal working example and I have a lot of tikz stuff in my actual code. For example I have these boxes shaded in my actual code and I just spent 30 min trying to figure out how I can do that with this tcolobox thing. – lo tolmencre Nov 17 '17 at 18:26