The mybox command is from this answer.
Original mybox
\newcommand\mybox[2][]{\tikz[overlay]\node[fill=black!20, inner sep=2pt,
anchor=text, rectangle, rounded corners=1mm,#1] {#2};\phantom{#2}}
If I use this command, I get results like below
I want it to have a bit more code like style, So I made it like below
\newcommand\mybox[2][]{\tikz[overlay]\node[fill=black!20, inner sep=2pt,
anchor=text, rectangle, rounded corners=1mm,\texttt{#1}] {#2};\phantom{#2}}
This one didn't even compile, so I searched and adjusted it to
\newcommand\mybox[2][]{\tikz[overlay]\node[fill=black!20,font=\ttfamily, inner sep=2pt,
anchor=text, rectangle, rounded corners=1mm,#1] {#2};\phantom{#2}}
This one compiled, but it wasn't what I wanted
So I made another command to wrap it.
\newcommand\mybox[2][]{\tikz[overlay]\node[fill=black!20, inner sep=2pt, anchor=text, rectangle, rounded corners=1mm,#1] {#2};\phantom{#2}}
\newcommand{\incode}[2][]{\mybox[#1]{\relscale{0.85}\texttt{#2}}}
I added some relative scaling because the font was bigger than I wanted it to be. The result I got is exactly what I want. However, I want to make these two commands in to one. Some help will be nice.
EDIT: MWE added
\documentclass[12pt, a4paper]{report}
\usepackage{tikz}
\usepackage{relsize} % relative scaling for font size
\newcommand\mybox[2][]{\tikz[overlay]\node[fill=black!20, inner sep=2pt, anchor=text, rectangle, rounded corners=1mm,#1] {#2};\phantom{#2}}
\newcommand{\incode}[2][]{\mybox[#1]{\relscale{0.85}\texttt{#2}}}
\begin{document}
Example \incode{0.2example} example
\end{document}




