4

Possible Duplicate:
Manual highlight of TeX code in a verbatim environment

I want to highlight certain parts of a program output listing which represent user input. For example I want to use \textbf in this way:

$ \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
...

I am unable to do it in listings and minted. Moreover I can't find a list of supported languages by minted in order to set it to bash output.

gc5
  • 141
  • minted uses a Python Pygments library. Look there for a list of supported languages. – Martin Scharrer May 16 '12 at 11:12
  • Thanks, this is the page.. By the way I cannot make \textbf work inside minted block. – gc5 May 16 '12 at 11:23
  • For a list of supported languages, use pygmentize -L lexers. :) – Paulo Cereda May 16 '12 at 11:24
  • Hi Francesco. Please take a look at this question and report if there is anything else you need. The answers partly provide pretty sophisticated ways of highlighting, but this one shows how to use the moredelim option of listings to apply simple font commands, such as \bfseries to highlight certain parts. – Daniel May 16 '12 at 12:09
  • I'll keep it as reference, thanks. I have found a solution in this question by inserting \DeclareFontShape{OT1}{cmtt}{bx}{n}{<5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>cmttb10}{} and using \begin{lstlisting}[escapechar=@]@\textbf{text}@ \end{lstlisting} – gc5 May 16 '12 at 12:48
  • Since I can't comment yet I'll write this as an answer, I hope this is not too inappropriate: This seems to be a near duplicate of this question: http://tex.stackexchange.com/a/41724/14576 There the solution was to use a laslisting environment, and do the formatting with the literate option \lstset – Andreas Wallner May 16 '12 at 11:28
  • @AndreasWallner: You have now over 50rep so you can comment everywhere. Please note that you can also flag a post as a duplicate using the 'flag' link below the post. – Martin Scharrer May 16 '12 at 19:05
  • @MartinScharrer thanks for the cleanup, did you "move" my answer to be a comment? I noticed it's already there when I wanted to write it again... Thanks though, didn't think it would be that fast to be able to comment – Andreas Wallner May 16 '12 at 21:06
  • @AndreasWallner: Yes, I converted your post to a comment. This is standard procedure in such cases. – Martin Scharrer May 16 '12 at 21:31

1 Answers1

1

I found a fast solution in an answer on this question. I had to add

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

and write my code block in this way (using listings)

\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}
gc5
  • 141