![コード一覧](https://rvso.com/image/305885/%E3%82%B3%E3%83%BC%E3%83%89%E4%B8%80%E8%A6%A7.png)
次のように、「リスト一覧」のエントリの後にハイフンを入れようとしています。
コード一覧
コード 1--最初のコード ................................ 7
コード2--第二コード ............................................... 8
次のコードでは...
\documentclass[12pt,openright,oneside,dvipsnames,a4paper,%
chapter=TITLE,section=TITLE,english]{abntex2}
\usepackage{textcomp}
\usepackage{caption}
\usepackage{listings}
\renewcommand{\lstlistingname}{Code} % Listings
\renewcommand{\lstlistlistingname}{List of Codes}%
\lstset{
language = [LaTeX]{TeX}
}
\AtBeginDocument{ %
\counterwithout{lstlisting}{chapter}
}
\begin{document}
\lstinputlisting[caption={First Code}]{code1.tex}
\lstinputlisting[caption={Second Code}]{code2.tex}
\end{document}
私は持っている:
コード一覧
コード 1 最初のコード .................................. 7
コード 2 2 番目のコード ............................... 8
ご協力いただければ幸いです。
答え1
ここで、tocloft
パッケージと一部egregの回答に\lstlistoflistings によって生成されたリストのリストをカスタマイズしますか?:
\documentclass[12pt,openright,oneside,dvipsnames,a4paper,%
chapter=TITLE,section=TITLE,english]{abntex2}
\usepackage{textcomp}
\usepackage{caption}
\usepackage{listings}
\usepackage{tocloft}
\renewcommand\lstlistingname{Code} % Listings
\renewcommand\lstlistlistingname{List of Codes}%
\lstset{
language = [LaTeX]{TeX}
}
\AtBeginDocument{ %
\counterwithout{lstlisting}{chapter}
}
\newlength\mylen
\begingroup
\makeatletter
\let\newcounter\@gobble\let\setcounter\@gobbletwo
\globaldefs\@ne \let\c@loldepth\@ne
\newlistof{listings}{lol}{\lstlistlistingname}
\newlistentry{lstlisting}{lol}{0}
\makeatother
\endgroup
\renewcommand\cftlstlistingpresnum{\lstlistingname~}
\settowidth\mylen{\cftlstlistingpresnum\cftlstlistingaftersnum}
\addtolength\cftlstlistingnumwidth{\mylen} %
\renewcommand\cftlstlistingaftersnum{\hfill\textendash\hfill}
\begin{document}
\lstlistoflistings
\begin{lstlisting}[caption={First Code}]
code1
\end{lstlisting}
\begin{lstlisting}[caption={Second Code}]
code2
\end{lstlisting}
\end{document}