I would like to change the original Listing 1.1: Caption style to 1.1. listing. Caption.
I've already found two possible solutions to this problem in the following thread: How can I reverse the caption numbering in listing. Unfortunately, none of them works for me. I suspect this is because the very specific way I am using listings.
Here is my config (that I created from lots of TexStackExchange posts) with a minimal working example.
\documentclass[12pt,a4paper,oneside]{report}
\usepackage{t1enc}
\usepackage[english,magyar]{babel}
\usepackage[utf8]{inputenc}
\usepackage[chapter]{minted}
\usepackage{tcolorbox} % https://tex.stackexchange.com/questions/305387/adding-a-caption-to-a-tcolorbox-tcblisting
\tcbuselibrary{listings,minted,skins,breakable}
\renewcommand*\thelstnumber{\ifnum\value{lstnumber}<10 0\fi\the\value{lstnumber}}
\renewcommand{\lstlistingname}{Kódrészlet}
\renewcommand{\listoflistingscaption}{Kódrészletek jegyzéke}
\makeatletter
\renewcommand\fnum@lstlisting{%
\ifx\lst@@caption\@empty\else\thelstlisting~\fi%
\lstlistingname}%
\makeatother
\makeatletter
\AtBeginDocument{\let\c@listing\c@lstlisting}
\makeatother
\AtBeginDocument{%
\newtcblisting[blend into=listings]{code}[3]{%
breakable,
colback=codebg,
colframe=black!40,
enhanced,
listing engine=minted,
listing only,
left=5mm,
overlay={\begin{tcbclipinterior}\fill[black!25] (frame.south west)
rectangle ([xshift=5mm]frame.north west);\end{tcbclipinterior}},
listing remove caption=false,
minted style=colorful,
minted language=#1,
minted options={linenos=true,numbersep=3mm,texcl=true,breaklines=true,autogobble=true},
coltitle=black,
attach boxed title to bottom center={yshift=-10pt},
boxed title style={enhanced jigsaw, colback=white, sharp corners, boxrule=0pt},
#2
}
}
\definecolor{codebg}{rgb}{0.95,0.95,0.95}
\newcommand{\listAref}[1]{\Aref{lst:#1}. kódrészlet}
\begin{document}
\tableofcontents\vfill
\newpage
\begin{otherlanguage}{english}
\begin{code}{swift}{title={Test title}, label={lst:test-code}}
import Foundation
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
}
\end{code}
\end{otherlanguage}
\listAref{test-code} egy tesztkódot mutat.
\listoflistings\addcontentsline{toc}{chapter}{Kódrészletek jegyzéke}
\end{document}
Everything is working fine but the fnum@lstlisting seems to be ignored(?). What am I doing wrong?


\documentclassto\end{document}. This way possible helpers won't have to imagine what kind of document are you compiling or what packages are you using. – Ignasi Dec 09 '16 at 08:51