Code: Select all
\renewcommand\lstlistingname{Slika}
\let\c@lstlisting\c@figure
\let\thelstlisting\thefigure
\let\ftype@lstlisting\ftype@figure
Thank you in advance.
Code: Select all
\renewcommand\lstlistingname{Slika}
\let\c@lstlisting\c@figure
\let\thelstlisting\thefigure
\let\ftype@lstlisting\ftype@figure
NEW: TikZ book now 40% off at Amazon.com for a short time.
\addcontentsline{lol}{lstlistings}{...}
and this is hard-coded in \lst@MakeCaption
. Either copy the code from listings.sty and change the settings or use a patch, that changes the relevant portions. In a normal setup, the 2nd \addcontentsline{lol}{lstlistings}{...}
command is active.\let\l@lstlisting\l@figure
as well!\addcontentsline
and check whether the first argument is a `lol` (then use `lof` instead) or fall back to the normal behaviour of \addcontentsline
.Code: Select all
\documentclass{article}
\usepackage{xpatch}
\usepackage{listings}
\makeatletter
\AtBeginDocument{%
\xpatchcmd{\lst@MakeCaption}{%
\lst@ifnolol\else
\ifx\lst@@caption\@empty
\ifx\lst@caption\@empty
\ifx\lst@intname\@empty \else \def\lst@temp{ }%
\ifx\lst@intname\lst@temp \else
\addcontentsline{lol}{lstlisting}\lst@name
\fi\fi
\fi
\else
\addcontentsline{lol}{lstlisting}%
{\protect\numberline{\thelstlisting}\lst@@caption}%
\fi
\fi
}{%
\lst@ifnolol\else
\ifx\lst@@caption\@empty
\ifx\lst@caption\@empty
\ifx\lst@intname\@empty \else \def\lst@temp{ }%
\ifx\lst@intname\lst@temp \else
\addcontentsline{lof}{lstlisting}\lst@name
\fi\fi
\fi
\else
\addcontentsline{lof}{lstlisting}%
{\protect\numberline{\thelstlisting}\lst@@caption}%
\fi
\fi
}{\typeout{Patch success!}}{\typeout{Patch failure}}
\renewcommand\lstlistingname{Slika}
\let\l@lstlisting\l@figure
\let\c@lstlisting\c@figure
\let\thelstlisting\thefigure
\let\ftype@lstlisting\ftype@figure
}
\makeatother
\begin{document}
\listoffigures
\begin{figure}
\caption{Foo figure}
\end{figure}
\begin{lstlisting}[language={C},caption={Hello World},label={foo}]
#include<stdio.h>
int main(int argc,char **argv)
{
printf("Hello World!\n");
return(0);
}
\end{lstlisting}
\end{document}
Code: Select all
\documentclass{article}
\usepackage{listings}
\usepackage{hyperref}
\makeatletter
% Grab the old \addcontentsline, which has been already being redefined by hyperref (eventually)
\let\latex@@addcontentsline\addcontentsline
\AtBeginDocument{%
\renewcommand{\addcontentsline}[3]{%
\def\@temp@a{#1}
\def\@temp@b{lol}
\ifx\@temp@a\@temp@b
\latex@@addcontentsline{lof}{#2}{#3}%
\else
\latex@@addcontentsline{#1}{#2}{#3}%
\fi
}
\renewcommand\lstlistingname{Slika}
\let\l@lstlisting\l@figure
\let\c@lstlisting\c@figure
\let\thelstlisting\thefigure
\let\ftype@lstlisting\ftype@figure
}
\makeatother
\begin{document}
\listoffigures
\clearpage
\begin{figure}
\caption{Foo figure}
\end{figure}
\clearpage
\begin{lstlisting}[language={C},caption={Hello World},label={foo}]
#include<stdio.h>
int main(int argc,char **argv)
{
printf("Hello World!\n");
return(0);
}
\end{lstlisting}
\end{document}
What does this mean? Both versions of the code works for standard setups. Since you have not provided really much, you seem to do strange things instead.bmandl wrote:Thank you all for replies. Unfortunately, above code doesn't do nothing in my case, so I decided to make separate list of listings. I am curious anyways
NEW: TikZ book now 40% off at Amazon.com for a short time.