Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I need to stress out some parts of string in lstlisting. I tried with \emph{}, but I got the verbatim result. Is there any way to that?

\begin{lstlisting}[frame=single]
Array1: 78 54 31 54 92 86 23 54 65 54 54 38 100 92 86 59 54 70 \emph{59 54 91 65 54 31 54 31 54 70 100 91 92 55 70 54 51 61 91 65 59 54 38 54 81 61 92 59 54 38 54 96 61 92} 59 54 38 54 81 54 92 90 54 92 88 36 65 59 54 38 54 101 61 92 59 54 38 54 96 61 92 59 54 38 54 101 54 92 90 54 92 88 88 86 98 115 54 70 54 66 89 54 91 65 54 54 38 75 54 70 91 92 59 54 38 54 31 54 70 61 91 92 54 31 54 31 54 70 54 91 92 88 88

Array2: 59 54 38 54 81 61 92 59 54 38 54 96 61 92 59 54 38 54 81 54 92 90 54 92 
\end{lstlisting}
share|improve this question
1  
    
While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. –  Peter Grill May 17 '13 at 5:52
add comment

1 Answer

up vote 5 down vote accepted

For example

\documentclass{article}


\usepackage{listings}

\begin{document}




\lstset{moredelim=[is][\itshape]{[}{]}}

\begin{lstlisting}[frame=single]
Array1: 78 54 31 54 92 86 23 54 65
 54 54 38 100 92 86 59 54 70 
[59 54 91 65 54 31 54 31 54 70
 100 91 92 55 70 54 51 61 91 
65 59 54 38 54 81 61 92 59 54 38 54 96 61 92]
59 54 38 54 81 54 92 90 54 92 88 36 65 59
 54 38 54 101 61 92 59 54 38 54 96 61 92 59
 54 38 54 101 54 92 90 54 92 88 88 86 98 11
5 54 70 54 66 89 54 91 65 54 54 38 75 54 
70 91 92 59 54 38 54 31 54 70 61 91 92 54
 31 54 31 54 70 54 91 92 88 88

Array2: 59 54 38 54 81 61 92 59 54 38 54 96 
61 92 59 54 38 54 81 54 92 90 54 92 
\end{lstlisting}

\end{document}

Delimiters are [ and ] and i means they are invisible.

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.