1 listings-tex-options.sty
2 ************************
3 highlight LaTeX code with lstlistings
4 =====================================
7 :Contact: milde@users.berlios.de
8 :Revision: $Revision: 5534 $
9 :Date: $Date: 2005-06-28$
10 :Copyright: © 2007, 2009 G. Milde,
11 Released without warranties or conditions of any kind
12 under the terms of the Apache License, Version 2.0
13 http://www.apache.org/licenses/LICENSE-2.0
18 For syntax highlight of literal blocks with the `listings` LaTeX package,
19 call ``rst2latex.py`` with the options
20 ``--stylesheet=listings-tex-options.sty --literal-block-env=lstlisting``.
22 Adapt the settings to your needs by either
24 * modifying a copy of this file under a different name, or
25 * copy parts of this file into your custom style sheet.
27 See listings.pdf_ for configuration and usage of the listings package.
36 \ProvidesPackage{listings-tex-options}
37 [2009/03/02 v0.1 highlight LaTeX with lstlistings]
39 Of course, we need to load the listings package itself::
41 \RequirePackage{listings}
43 In a document with lots of lists and listings, separating paragraphs by
44 vertical seems appropriate::
46 \RequirePackage{parskip}
48 load hyperref with blue citation colour::
50 \RequirePackage[colorlinks=true,linkcolor=blue,urlcolor=blue,citecolor=blue]
53 In the References/Bibliography section,
54 avoid holes in the title due to block alignment::
56 \renewcommand{\titlereference}[1]{\raggedright\textsl{#1}}
58 Omit the auto-inserted "References" heading, to be compatible with HTML
59 output also if use latex references is set::
61 \AtBeginDocument{\renewcommand{\refname}{\vspace{-2em}}}
66 Times, Helvetica, Courier::
68 %\RequirePackage{mathptmx}
69 %\RequirePackage[scaled=.90]{helvet} % scaled to fit Times
70 %\RequirePackage{courier}
72 Palatino, Helvetica, Courier::
74 \RequirePackage[sc]{mathpazo} % with small caps
75 % \RequirePackage[sc,osf]{mathpazo} % with small caps and old style figures
76 \RequirePackage[scaled=.95]{helvet} % scaled to fit Palatino
77 \RequirePackage{courier}
79 (The TX typewriter font comes with bold, slanted, and small-caps variants
80 and without the problems of `txfonts`' math fonts). However, `txfonts` is
81 a contributed package, not necessarily available::
83 %\renewcommand{\ttdefault}{txtt}
89 Highlight literal blocks as TeX::
91 \lstset{language=[LaTeX]TeX}
93 pre-load the language::
95 \lstloadlanguages{[LaTeX]TeX} % comma separated list of languages
103 basicstyle=\ttfamily, % print whole listing in tt
104 % basicstyle=\ttfamily\small,
105 keywordstyle={}, % do not highlight keywords
106 % identifierstyle=\slshape, % macros that are not keywords, args
107 commentstyle=\rmfamily\itshape, % italic comments
108 % stringstyle=\ttfamily, % typewriter type for strings
109 % texcsstyle=\slshape,
114 \lstset{showstringspaces=false} % no visible spaces in strings
115 %\lstset{showspaces=true,
117 % tab=\rightarrowfill}
121 %\lstset{numbers=left, numberstyle=\tiny, stepnumber=2, numbersep=5pt}
123 Frames around listings::
125 %\lstset{frame=single}
128 Extended characters in listings::
136 (for typesetting with variable width fonts)
138 ``columns=[c|l|r] <alignment>``
139 <alignment> in [fixed, flexible, spaceflexible, or fullflexible]
141 The optional c, l, or r controls the horizontal orientation of smallest
142 output units (keywords, identifiers, etc.).
146 ``basewidth={fixed, flexible}``
149 sets the width of a single character box for fixed and flexible column
150 mode (both to the same value or individually).
152 default: {0.6em,0.45em}
154 Free spacing for comments::
156 \lstset{columns=fullflexible, basewidth={0.5em,0.4em}}
159 ftp://dante.ctan.org/tex-archive/macros/latex/contrib/listings/listings.pdf