\listof 无标题

\listof 无标题

过去我问过如何排版标题\listofXtocloft包中。我记得从那时起,我找到了一种方法来完全隐藏标题,这样我就可以使用\section{X}它代替标题,我发现这更方便。问题:我忘了怎么做,除了它涉及\makeatletter+\makeatother习语。那会是什么?

%\RequirePackage{background}
\documentclass{article}
\usepackage{mwe}
\usepackage{lipsum}
%\usepackage[pages=some, placement=bottom]{background}
\usepackage[pages=some]{background}
%\usepackage{tocloft}
\usepackage[titles]{tocloft} % https://tex.stackexchange.com/questions/553871/how-to-typeset-listof

%\newlistof[〈within〉]{〈entry〉}{〈ext〉}{〈listofname〉}

\newlistof{answer}{ans}{Answer}%\listanswername}

\newcommand{\answer}[1]{%
\refstepcounter{answer}
\par\noindent{Answer \theanswer. #1}
\addcontentsline{ans}{answer}{\protect\numberline{\theanswer}#1}\par}

\makeatletter
\@cfthaschapterfalse
\makeatother

\begin{document}

% \section{Answer}
\listofanswer\par

\medskip

\answer{\lipsum[1][1]}

\end{document}

在此处输入图片描述

答案1

像这样:

\documentclass{article}
\usepackage{mwe}
\usepackage{lipsum}
\usepackage[titles]{tocloft} % https://tex.stackexchange.com/questions/553871/how-to-typeset-listof

%\newlistof[〈within〉]{〈entry〉}{〈ext〉}{〈listofname〉}

\newlistof{answer}{ans}{Answer}%\listanswername

\newcommand{\answer}[1]{%
\refstepcounter{answer}
\par\noindent{Answer \theanswer. #1}
\addcontentsline{ans}{answer}{\protect\numberline{\theanswer}#1}\par}

\makeatletter
%\@cfthaschapterfalse %Don't need 
\def\listofanswer{\@cfttocstart\@nameuse{cftmarkans}\@starttoc{ans}\@cfttocfinish}
\makeatother

\begin{document}

\section*{Answer}
\listofanswer\par

\medskip

\answer{\lipsum[1][1]}
\end{document}

在此处输入图片描述

相关内容