![코드 목록](https://rvso.com/image/305885/%EC%BD%94%EB%93%9C%20%EB%AA%A9%EB%A1%9D.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 두 번째 코드 .......................................... 8
도움을 주셔서 미리 감사드립니다.
답변1
다음은tocloft
패키지와 그 일부에그레그의 답변에게\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}