3

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

2 Answers2

2

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}

enter image description here

-1

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}
Dharman
  • 30,962
  • 25
  • 85
  • 135
riccardogabellone
  • 268
  • 1
  • 6
  • 17