TeXnik - Tips TeX and LaTeX


Welcome to the TeXnik website (under construction)

Sourcecode Listings Examples
TUG logo

Main page

Index
UK FAQ
Documentation
Software
CTAN
Search CTAN:

Statistics

Google c.t.t.

Google d.c.t.t.

 


 


Literate programming

If you want some words emphasized you can use the emph option. But this does not work for single charcters like digits. In this case the literate option may help. In the following example all digits in the listing should be colored red.


Special linebreak symbol

\usepackage{listings}
\newcommand{\MyHookSign}{\hbox{\ensuremath\hookleftarrow}}
%
\begin{document}
\lstset{% general command to set parameter(s)
	language=Java,
	basicstyle=\small,
	tabsize=4,
	tab=$\to$,
	float=tbph,
	extendedchars,
	breaklines,
	prebreak={\space\MyHookSign},
	frame=single,
	showtabs=false,
	showspaces=false,
	showstringspaces=false,
	keywordstyle=\bfseries,
	identifierstyle=\ttfamily,
	stringstyle=,
	captionpos=b,
	aboveskip=\bigskipamount,
}
This gives a listing with a special symbol for breaking lines.

Colored listings




Special environment



Special highlight




Inline code


local time: Thu Mar 28 23:41:08 CET 2024 ; file is: 1740.58726851852 days old
contact webmaster _at_ TeXnik.de