如何突出显示乳胶中的内联代码片段?

How to highlight an inline code snippet in latex?

我想突出显示正文中间的一段代码。我希望它看起来类似于 markdown 中的 inline heightlight。

我希望它看起来像这样:tensorflow.keras.optimizers

您可以使用这两个包(minted、xcolor),如下例所示

\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}

您可以使用 listingtcolorbox 包:

\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}