0

I created two lstnewenvironment, one for Java, and one for pseudocode as following: (pseudocode not included here)

\documentclass{thesisPST}
\usepackage{listings}

\lstnewenvironment{java}[1][]
    {\lstset{
        language=Java,
        backgroundcolor=\color{light-backcolour},
        xleftmargin=0.7cm,
        frame=tlbr,
        framesep=0.2cm, 
        framerule=0pt,
        commentstyle=\color{codegray},
        keywordstyle=\color{codeblue},
        numberstyle=\tiny\color{codegray},
        stringstyle=\color{pgreen},
        basicstyle=\footnotesize\ttfamily,
        breakatwhitespace=false,
        breaklines=true,
        captionpos=b,
        keepspaces=true,
        numbers=left,
        numbersep=5pt,
        showspaces=false,
        showstringspaces=false,
        showtabs=false,                  
        tabsize=2,
        mathescape=true,
        framexleftmargin=5mm,
        stepnumber=1,
        morekeywords={},
        deletekeywords={},
        identifierstyle=,
        moredelim=[il][\textcolor{codepurple}]{\$\$},
        moredelim=[is][\textcolor{codepurple}]{\%\%}{\%\%},
        moredelim=[il][\textcolor{codegold}]{@}
    }
}{}


\begin{document}

\frontmatter
\tableofcontents

\mainmatter

%after i created some code such as:
\begin{java}[caption=Die Methode doesAutomatExists ,label = c:doesAutomatExists]
    private boolean doesAutomatExists(String automatonName, List<ComponentAutomaton> automata){
        boolean res = true;
        for (ComponentAutomaton automaton:automata) {
            if (automaton.getAutomatonName().equals(automatonName)){ 
                res = false;
            }
        }
        return res;
    }
\end{java}


\backmatter
%Next i created a lstlistoflistings as following:
%but the list is empty
\phantomsection
\renewcommand\lstlistlistingname{Quellcodeverzeichnis}
\addcontentsline{toc}{chapter}{Quellcodeverzeichnis} 
\lstlistoflistings
\end{document}

where did I go wronge?

  • 1
    It is impossible to debug disconnected fragments like that, please edit your question so the example is a single small document that shows the problem. Have you run latex enough times for the list to be complete? – David Carlisle Jan 25 '18 at 0:11
  • @DavidCarlisle, I did.The lstlistoflistings ist there for already a month and I work almost everyday on the Doc. – Subhi Samara Jan 25 '18 at 0:26
0

After looking close to the lstset, and the PDF, I saw that the codes does not have a caption.

By not having a caption, the lstlistinging wot appear in the thable of listings.

In order to solve this, I added two lines to the lstset under the lstnewenvironment.

1. `caption= #1`
2. captionpos=b

so I defined in which position the caption will be: e.g.

\begin{java}[language=java,caption=Die Methode doesAutomatExists ,label = c:doesAutomatExists]

and the caption was shown under the code, and added to the table.

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.