I would like to hightlight a piece of code in the middle of a body of text. I would like it to appear similar to the inline heightlight in markdown.
I want it to look like this: tensorflow.keras.optimizers
I would like to hightlight a piece of code in the middle of a body of text. I would like it to appear similar to the inline heightlight in markdown.
I want it to look like this: tensorflow.keras.optimizers
You can use the listing
and tcolorbox
packages:
\documentclass{article}
\usepackage{xspace}
\usepackage{tcolorbox}
\tcbuselibrary{listings}
\newtcblisting{foo}{
listing only,
nobeforeafter,
after={\xspace},
hbox,
tcbox raise base,
fontupper=\ttfamily,
colback=lightgray,
colframe=lightgray,
size=fbox
}
\begin{document}
text
\begin{foo}
code
\end{foo}
text
\end{document}
You can use this two packages (minted, xcolor) as shown in the example below
\documentclass{article}
\usepackage{minted}
\usepackage{xcolor}
\definecolor{code_gray}{rgb}{0.8,0.8,0.8}
\begin{document}
This is an \colorbox{code_gray}{\mintinline{HTML}{<a>}} HTML tag.
\end{document}