You can use any (All)TeX macro you wish within listings by enclosing it within escape brackets,
(*@ \textcolor{blue}{code} @*)
The funny eyes are the escapes you define them as follows:
\lstset{escapeinside={(*@}{@*)}}
For highlighting the soul
package provides a nice highlight macro \hl
, try it in the following minimal
\documentclass{article}
\usepackage{soul,listings,xcolor}
\lstnewenvironment{teX}[1][]
{\lstset{language=[LaTeX]TeX}\lstset{escapeinside={(*@}{@*)},
numbers=left,numberstyle=\normalsize,stepnumber=1,numbersep=5pt,
breaklines=true,
%firstnumber=last,
%frame=tblr,
framesep=5pt,
basicstyle=\normalsize\ttfamily,
showstringspaces=false,
keywordstyle=\itshape\color{blue},
%identifierstyle=\ttfamily,
stringstyle=\color{maroon},
commentstyle=\color{black},
rulecolor=\color{black},
xleftmargin=0pt,
xrightmargin=0pt,
aboveskip=\medskipamount,
belowskip=\medskipamount,
backgroundcolor=\color{white}, #1
}}
{}
\begin{document}
\begin{teX}
\test{this is some code}
(*@ \textcolor{blue}{code} @*)
(*@ \hl{yellow code} @*)
\end{teX}
\end{document}
I normally use an environment for "listings" settings, but you can use any other code style as well.
Another useful trick is to use the "listings" setting for emphasis in macros, like this:
\gdef\emphasis#1{\lstset{emph={begin,end,#1},
emphstyle={\itshape\ttfamily\textcolor{blue}}}}
\gdef\hlemphasis#1{\lstset{emph={begin,end,#1},
emphstyle={\hl{blue}}}}
This way you can emphasize keywords.
This minimal example, following your description, shows that it can be compiled without that error message complaining about \citet
being undefined:
\documentclass{article}
\usepackage[natbib=true,style=alphabetic-verb,sorting=nty,hyperref,backend=bibtex8]{biblatex}
\begin{document}
al trabajo de \citet{Fernandez2007}.
\end{document}
However, I can confirm, that the error
! Undefined control sequence.
l.4 al trabajo de \citet
{Fernandez2007}.
would occur if no options to biblatex are used, i.e. if I just write \usepackage{biblatex}
. This doesn't depend on the listings
package.
Best Answer
Option 1: Use the
listings
packageSimple configuration for LaTeX header (before
\begin{document}
):You can change default language in the middle of document with
\lstset{language=Java}
.Example of usage in the document:
Here's the result:
Option 2: Use the
verbatim
environment