我正在尝试使用使用 minted 和 newfloat 将“Figure”作为 listoflistings 中列表的名称修复了,但不起作用。Latex 一直将铸造环境显示为图形而不是听力:
\documentclass[10pt,a5paper]{abntex2}
\usepackage[brazil]{babel}
\usepackage{listings}
\usepackage{caption}
\usepackage{newfloat}
\usepackage{etoolbox}
% https://tex.stackexchange.com/questions/57353/how-to-get-caption-above-listing-with-minted
\usepackage[newfloat,chapter]{minted}
\captionsetup[listing]{position=top}
\newenvironment{code}{\captionsetup{type=listing}}{}
% https://tex.stackexchange.com/questions/269491/mixing-minted-with-lstlisting
\AtBeginEnvironment{listing}{\setcounter{listing}{\value{lstlisting}}}
\AtEndEnvironment{listing}{\stepcounter{lstlisting}}
% https://tex.stackexchange.com/questions/287947/figure-as-name-of-listings-in-listoflistings-with-minted-and-newfloat/287953#287953
\makeatletter
\let\l@listing\l@figure
\def\newfloat@listoflisting@hook{\let\figurename\listingname}
\makeatother
\begin{document}
\lstlistoflistings
\chapter{Formatador}
\begin{code}
\caption{My Func}
\label{lst:my_func}
\inputminted[fontsize=\small,linenos=true,numberblanklines=true,breaklines=true]{latex}{test1.tex}
\end{code}
\end{document}
答案1
我通过替换来修复它\lstlistoflistings
:
{%
\renewcommand{\cftfigurename}{\listingname\space}
\lstlistoflistings
}