
我怎麼能讓\emph{}
看起來像this
StackExchange 突出顯示一樣。
我喜歡 StackExchange 論壇系列的突出顯示,並希望在我的 Latex 文件中使用它。
抱歉,我無法用語言表達我的問題,所以我無法自己用谷歌搜尋。
答案1
您需要重新定義\emph
命令,並且需要color
套件為您提供陰影框。嘗試這個:
\documentclass{article}
\usepackage{color}
\definecolor{light-gray}{gray}{0.85}
\renewcommand\emph[1]{\colorbox{light-gray}{\texttt{#1}}}
\begin{document}
This is some \emph{marked} text.
\end{document}
然而,有一種更聰明的方法可以做到這一點,讓您可以像 SE 一樣使用反引號,使用newverbs
和shortvrb
套件:
\documentclass{article}
\usepackage{color}
\definecolor{light-gray}{gray}{0.85}
\usepackage{newverbs}
\usepackage{shortvrb}
\newverbcommand{\cverb}
{\setbox\verbbox\hbox\bgroup}
{\egroup\colorbox{light-gray}{\box\verbbox}}
\MakeSpecialShortVerb{\cverb}{\`}
%
\begin{document}
This is some `quoted` text, that allows `\TeX` macros to be shown without expansion.
\end{document}
但是,如果您想像 Knuth 最初在 plain TeX 中那樣使用左手印刷引號的反勾號,請不要這樣做。
並且(正如評論中所指出的)將內容放入這樣的框中可以防止框內換行,因此這種方法僅適用於短文本,您應該準備重寫以避免過度或不足線。