\lstlistoflistings タイトルのスタイルを再定義するにはどうすればよいですか?

\lstlistoflistings タイトルのスタイルを再定義するにはどうすればよいですか?

memoir私はとパッケージに基づく cls を使用していますlistings。すべてのリスト (表のリスト、図のリスト、リストのリスト) を含む付録の章が必要です。これらのリストのタイトル スタイルは、タイトルのようになりますsection

表と図の場合は次のように実行できます。

\makeatletter
\renewcommand\@lofmaketitle{%
  \section*{\listfigurename}%
  \tocmark%
  \@afterheading}
\makeatother

\makeatletter
\renewcommand\@lotmaketitle{%
  \section*{\listtablename}%
  \tocmark%
  \@afterheading}
\makeatother

したがって、リストにも機能するはずだと考えましたが、次のコードは効果がありません。

\makeatletter
\renewcommand\@lolmaketitle{%
  \section*{\lstlistlistingname}%
  \tocmark%
  \@afterheading}
\makeatother

私はそれを使用する\lstlistoflistings*ので、TOC に表示されたくありません。

これどうやってするの?

答え1

これでいいはずだ

\documentclass[a4paper]{memoir}
\usepackage{listings}
\begin{document}
\begin{lstlisting}[caption=Hest]
a
\end{lstlisting}


\begingroup

\makeatletter
\renewcommand\@tocmaketitle{%
  \section*{\contentsname}%
  \markboth{\contentsname}{\contentsname}
  \@afterheading}
\makeatother

% adding a star to \lstlistoflistings does not work, the inner 
% \tableofcontents never sees it. Locally use \KeepFromToc 
% to emulate the *
\KeepFromToc
\lstlistoflistings
\endgroup

\end{document}

変更は にも影響するため、実際にはプリアンブル内で行うことはできないことに注意してください\tableofcontents

関連するコードlistings

\lst@UserCommand\lstlistoflistings{\bgroup
    \let\contentsname\lstlistlistingname
    \let\lst@temp\@starttoc \def\@starttoc##1{\lst@temp{lol}}%
    \tableofcontents \egroup}

\contentsnameここで、リセットされ、どのファイル\@starttocが使用されるかがわかります。\tableofcontents通常は実行される\@starttocので、単に実行されます\tableofcontents

関連情報