在列表或铸造中突出显示某些文本

在列表或铸造中突出显示某些文本

可能重复:
在逐字环境中手动突出显示 TeX 代码

我想突出显示程序输出列表中代表用户输入的某些部分。例如,我想\textbf以这种方式使用:

$ \textbf{dmesg | tail}

...
[ 6854.215650] sd 7:0:0:0: [sdc] Mode Sense: 0b 00 00 08
[ 6854.215653] sd 7:0:0:0: [sdc] Assuming drive cache: write through
[ 6854.215659] sdc: sdc1
[ 6854.218079] sd 7:0:0:0: [sdc] Attached SCSI removable disk
[ 6854.218135] sd 7:0:0:0: Attached scsi generic sg2 type 0
...

我无法在listings和中执行此操作minted。此外,我找不到 minted 支持的语言列表,无法将其设置为 bash 输出。

答案1

我在以下答案中找到了快速解决方案这个问题我必须补充一下

\DeclareFontShape{OT1}{cmtt}{bx}{n}{<5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>cmttb10}{}

并以这种方式编写我的代码块(使用列表)

\begin{lstlisting}[escapechar=@]
$ @\textbf{dmesg | tail}@ 

...
[ 6854.215650] sd 7:0:0:0: [sdc] Mode Sense: 0b 00 00 08
[ 6854.215653] sd 7:0:0:0: [sdc] Assuming drive cache: write through
[ 6854.215659] sdc: sdc1
[ 6854.218079] sd 7:0:0:0: [sdc] Attached SCSI removable disk
[ 6854.218135] sd 7:0:0:0: Attached scsi generic sg2 type 0
...
\end{lstlisting}

相关内容