0

Hey guys I follow the instructions to create a short title with the package listings.

My code looks like:

\begin{lstlisting}[caption={[Beispiel JSON Array mit zwei Objekten]{Beispiel JSON Array mit zwei Objekten Quelle: \autocite[8]{crockford_application/json_2006}}}
\label{lst:json},captionpos=b,language=JavaScript, frame=single]
[
    {
        "precision": "zip",
        "Latitude": 37.7668,
        "Longitude": -122.3959,
        "Address": "",
        "City": "SAN FRANCISCO",
        "State": "CA",
        "Zip": "94107",
        "Country": "US"
    },
    {
        "precision": "zip",
        "Latitude": 37.371991,
        "Longitude": -122.026020,
        "Address": "",
        "City": "SUNNYVALE",
        "State": "CA",
        "Zip": "94085",
        "Country": "US"
    }

\end{lstlisting}

But my output shows the short title and the long title.

enter image description here

Does anyone have a idea why this happens?

Full Example:

\documentclass[12pt,a4paper,titlepage,pdftex,chapterprefix=true]{scrbook}

\usepackage[autooneside=false,headsepline,markcase=noupper]{scrlayer-scrpage}
\automark[subsection]{section}
\pagestyle{scrheadings}
\clearscrheadfoot
\ofoot[\pagemark]{\pagemark}
%\ohead{\ifstr{\rightbotmark}{\leftmark}{}{\rightbotmark}}
\ihead{\leftmark}
\usepackage{amssymb}
%Colspan und Rowspan ermöglichen
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{multirow}
%Grafiken einbinden
\usepackage{graphicx} 
\usepackage{epstopdf}
\usepackage{float}
\usepackage{array}
\usepackage{floatflt}
\usepackage{wrapfig}
\usepackage{subfigure} 
%\usepackage{eurosym}
%Icons
%\usepackage{bbding}
\usepackage{marvosym}
%Plots mit Latex erstellen
\usepackage{pgfplots}
%Graphen aller Art erstellen
\usepackage{tikz}
\usetikzlibrary{patterns}
%Quellcode darstellen 
\usepackage{listings}
\usepackage{color}
\definecolor{middlegray}{rgb}{0.5,0.5,0.5}
\definecolor{lightgray}{rgb}{0.8,0.8,0.8}
\definecolor{orange}{rgb}{0.8,0.3,0.3}
\definecolor{yac}{rgb}{0.6,0.6,0.1}
\definecolor{darkgray}{rgb}{.4,.4,.4}
\definecolor{purple}{rgb}{0.65, 0.12, 0.82}
\renewcommand{\lstlistingname}{Auflistung}
\renewcommand{\lstlistlistingname}{Auflistungen}
\lstdefinelanguage{JavaScript}{
    keywords={typeof, new, true, false, catch, function, return, null, catch, switch, var, if, in, while, do, else, case, break},
    keywordstyle=\color{blue}\bfseries,
    ndkeywords={class, export, boolean, throw, implements, import, this},
    ndkeywordstyle=\color{darkgray}\bfseries,
    identifierstyle=\color{black},
    sensitive=false,
    comment=[l]{//},
    morecomment=[s]{/*}{*/},
    commentstyle=\color{purple}\ttfamily,
    stringstyle=\color{red}\ttfamily,
    morestring=[b]',
    morestring=[b]"
}
\lstset{
    basicstyle=\scriptsize\ttfamily,
    keywordstyle=\bfseries\ttfamily\color{orange},
    stringstyle=\color{green}\ttfamily,
    commentstyle=\color{middlegray}\ttfamily,
    emph={square}, 
    emphstyle=\color{blue}\texttt,
    emph={[2]root,base},
    emphstyle={[2]\color{yac}\texttt},
    showstringspaces=false,
    flexiblecolumns=false,
    tabsize=2,
    numbers=left,
    numberstyle=\tiny,
    numberblanklines=false,
    stepnumber=1,
    numbersep=10pt,
    xleftmargin=15pt,
    numberbychapter=true,
    breaklines=true
}
%Abbildungen mit Kapitelnummern
%\usepackage{chngcntr}
%\counterwithin{figure}{section}
%\counterwithin{table}{section}
%\counterwithin{lstlisting}{section}
\usepackage{caption3}
%Abkürzungsverzeichnis
%\usepackage{acronym}
%Deutsche Bezeichnungen und Umlaute
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{ae}
\usepackage[ngerman]{babel}
%\usepackage{lmodern}
%\usepackage[ngerman]{translator}
%Einstellungen für die Tiefe der Überschriften
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{3} 
%Zeilenabstand
\usepackage{setspace}
%\makeatletter
% Damit die letzte (\botmark) statt der ersten (\firstmark) Marke auf
% einer Seite für die "rechte Marke" genommen wird:
\providecommand*{\rightbotmark}{\expandafter\@rightmark\botmark\@empty\@empty}
%\makeatother
\usepackage{xcolor} 
%Haken und Kreuze deffinieren
\usepackage{pifont}% http://ctan.org/pkg/pifont
\newcommand{\cmark}{\ding{51}}%
\newcommand{\xmark}{\ding{55}}%
\newcommand{\ccmark}{\color{green}\ding{51}\color{black}}%
\newcommand{\cxmark}{\color{red}\ding{55}\color{black}}%
\usepackage{framed} 
\newenvironment{balken}{% minimale Abwandlung von leftbar 
  \def\FrameCommand##1{\textcolor{red}{\vrule width 3pt} \hspace{10pt}##1}% 
  \MakeFramed {\advance\hsize-\width \FrameRestore}}% 
 {\endMakeFramed} 
\newcommand*{\tip}{\hspace{-25pt}\colorbox{red}{\textbf{\textcolor{white}{ Hinweis\\ }}}} 

%Literaturverzeichnis laden
\input{literaturVz.tex}
%Glossar einbinden
\usepackage[colorlinks]{hyperref}%Farbige Links
%\usepackage{hyperref}
\usepackage[xindy,
nonumberlist, %keine Seitenzahlen anzeigen
acronym,      %ein Abkürzungsverzeichnis erstellen
toc          %Einträge im Inhaltsverzeichnis
]      %im Inhaltsverzeichnis auf section-Ebene erscheinen
{glossaries}
\makeglossaries

\begin{lstlisting}[caption={[Beispiel JSON Array mit zwei Objekten]{Beispiel JSON Array mit zwei Objekten Quelle: \autocite[8]{crockford_application/json_2006}}}
\label{lst:json},captionpos=b,language=JavaScript, frame=single]
[
    {
        "precision": "zip",
        "Latitude": 37.7668,
        "Longitude": -122.3959,
        "Address": "",
        "City": "SAN FRANCISCO",
        "State": "CA",
        "Zip": "94107",
        "Country": "US"
    },
    {
        "precision": "zip",
        "Latitude": 37.371991,
        "Longitude": -122.026020,
        "Address": "",
        "City": "SUNNYVALE",
        "State": "CA",
        "Zip": "94085",
        "Country": "US"
    }
]
\end{lstlisting}
\end{document}

Thanks in advance.

  • Welcome, the instructionn doesn't work. documentclass is missing, there is no document environment etc. We cannot reproduce your issue. – Johannes_B Oct 3 '17 at 9:55
  • I updated the question an add an full example. – dominic Oct 3 '17 at 10:01
  • I refuse to run this code a second time. Put a real minimal working example into your question. – Johannes_B Oct 3 '17 at 10:16
1

I found the error by searching for another problem.

\begin{lstlisting}[caption={[Beispiel JSON Array mit zwei Objekten]{Beispiel JSON Array mit zwei Objekten Quelle: \autocite[8]{crockford_application/json_2006}}}
\label{lst:json},captionpos=b,language=JavaScript, frame=single]

has to be:

   \begin{lstlisting}[caption={[Beispiel JSON Array mit zwei Objekten]{Beispiel JSON Array mit zwei Objekten Quelle: \autocite[8]{crockford_application/json_2006}}}
    ,label={lst:json},captionpos=b,language=JavaScript, frame=single]

so you need to change \label{} to label={} than all works like expected. This also fix the error that the references got wrong numbers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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