I am using the package sidecap
for captions which appear left or right of a picture/table, like so:
\documentclass[a4paper,twoside,11pt,openright]{scrbook}
\usepackage{graphicx}
\usepackage[wide]{sidecap}
\usepackage[font=footnotesize,
format=plain,
labelfont={bf,sf},
textfont={it},
width=10pt]{caption}
\newcommand{\fig}[4]{
\begin{SCfigure}
\centering
\includegraphics[width=\textwidth]{#1}
\caption[#2]{#3}
\label{fig:#4}
\end{SCfigure}
}
And the, within the document:
\begin{document}
\fig{background_flickr.png}{Flickr geotagging functionality}{Flickr geotagging functionality. By navigating and panning on a map, the user can place an image or video and specify the desired level of spatial granularity.}{background_flickr}
\end{document}
Which yields:
I am also using the package listings
for code, and the settings look like this:
\usepackage{listings}
\lstset{
backgroundcolor=\color{lightgray},
extendedchars=true,
basicstyle=\footnotesize\ttfamily,
xleftmargin=20pt,
showstringspaces=false,
showspaces=false,
numbers=left,
numberstyle=\footnotesize,
tabsize=2,
breaklines=true,
showtabs=false,
captionpos=tb
}
Inserting a code listing like this
\begin{lstlisting}[caption={[JSON Example]A basic JSON example}, label=src:DataTwitterAPIJSON]
{
"firstName": "John",
"lastName": "Smith",
"age": 25,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": 10021
},
"phoneNumbers": [
{
"type": "home",
"number": "212 555-1234"
},
{
"type": "fax",
"number": "646 555-4567"
}
]
}
\end{lstlisting}
yields:
There are two problems: First of all, the caption does not get displayed correctly at all (seems to be very narrow). Secondly, I need it to be on the left of the listing on left pages and on the right of the listing on right pages (like the normal sidecap
behavior above). I suspect that the "narrow" look somehow comes from the sidecap
package. Is there no way to not only use sidecap
for figures and tables but also for listings?
listing
float environment