Liste der Eintragsnamen in der Kopfzeile

Liste der Eintragsnamen in der Kopfzeile

Ich habe ein zweiseitiges bookDokument und möchte die Kopfzeile so formatieren, dass der Kapitelname außen steht. Alles funktioniert gut, aber eine Sache ärgert mich. Ich habe einige Quellcode-Auflistungen ( listingsPaket) und Pseudocodes ( algorithmicxPaket). Alle Kapitelnamen sind „normal“ angegeben, aber die Liste der Auflistungen (mit dem Namen „Auflistungen“) und die Liste der Algorithmen sind in Großbuchstaben in die Kopfzeile geschrieben.

Ich muss wahrscheinlich einige Einstellungen für diese Pakete überschreiben, kann aber nicht herausfinden, welche. Wie kann ich die Art und Weise ändern, in der „Listings“ und „Liste der Algorithmen“ vom \chaptermarkBefehl eingegeben werden (falls dies die richtige ist)?

Hier ist ein kleines Beispiel, das das Problem verdeutlicht:

\documentclass[a4paper,twoside]{book}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{listings}

\fancypagestyle{fancyplain}{%
\renewcommand{\headrulewidth}{0pt}
\fancyhf{}%
\renewcommand{\footrulewidth}{0pt}
\fancyfoot{\fancyplain}{}
}

\pagestyle{fancy}

\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{thesection\ #1}{}}

\renewcommand{\lhead}[1]{\fancyhead[OL,ER]{\fancyplain{}\chaptermark{#1}}}
\fancyhead[OR,EL]{\fancyplain{}\thepage}

\begin{document}

\chapter{My chapter}
\begin{lstlisting}[caption={My listing},label=lst:my_listing,language=C++]
  std::cout << "Hello World!" << std::endl;
\end{lstlisting}
\cleardoublepage

\lstlistoflistings
\addcontentsline{toc}{chapter}{Listings}
\thispagestyle{empty}
\cleardoublepage

\end{document}

Antwort1

Eine Möglichkeit besteht darin, es zu entfernen oder \tableofcontentsdurch eine geänderte Version zu ersetzen, die nicht über verfügt \MakeUppercase\contentsname.

\documentclass[a4paper,twoside]{book}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{listings}

\usepackage{xpatch}



\makeatletter

\newcommand{\othertableofcontents}{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\contentsname
        \@mkboth{%
          \contentsname}{\contentsname}}%
    \@starttoc{toc}%
    \if@restonecol\twocolumn\fi
}
\makeatother

\xpatchcmd{\lstlistoflistings}{%\
  \tableofcontents}{%
  \othertableofcontents}{}{}

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

\fancypagestyle{fancyplain}{%
\renewcommand{\headrulewidth}{0pt}
\fancyhf{}%
\renewcommand{\footrulewidth}{0pt}
\fancyfoot{\fancyplain}{}
}

\pagestyle{fancy}

\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{thesection\ #1}{}}

\renewcommand{\lhead}[1]{\fancyhead[OL,ER]{\fancyplain{}\chaptermark{#1}}}
\fancyhead[OR,EL]{\fancyplain{}\thepage}

\begin{document}

\chapter{My chapter}
\begin{lstlisting}[caption={My listing},label=lst:my_listing,language=C++]
  std::cout << "Hello World!" << std::endl;
\end{lstlisting}
\cleardoublepage

\lstlistoflistings
\addcontentsline{toc}{chapter}{Listings}
\thispagestyle{empty}
\cleardoublepage

\end{document}

Aktualisieren

Da der OP darum gebeten hat, Überschriften für usw. nicht in Großbuchstaben zu haben ToC, schlage ich vor, sie aus dem Paket LoTzu verwenden .\cftmarkXtocloft

Ich habe dies getan und die relevanten Befehle \markboth{...}{...}für beide Seitenränder neu definiert – das ist in Ordnung, da der OP später sowieso eine Neudefinition vornimmt.

\documentclass[a4paper,twoside]{book}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{listings}
\usepackage{tocloft}


\renewcommand{\cftmarktoc}{\markboth{\contentsname}{\contentsname}}
\renewcommand{\cftmarklof}{\markboth{\listfigurename}{\listfigurename}}
\renewcommand{\cftmarklot}{\markboth{\listtablename}{\listtablename}}


\fancypagestyle{fancyplain}{%
\renewcommand{\headrulewidth}{0pt}
\fancyhf{}%
\renewcommand{\footrulewidth}{0pt}
\fancyfoot{\fancyplain}{}
}

\pagestyle{fancy}

\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{thesection\ #1}{}}

\renewcommand{\lhead}[1]{\fancyhead[OL,ER]{\fancyplain{}\chaptermark{#1}}}
\fancyhead[OR,EL]{\fancyplain{}\thepage}

\begin{document}
\tableofcontents
\cleardoublepage
\listoffigures
\cleardoublepage
\listoftables
\chapter{My chapter}
\begin{lstlisting}[caption={My listing},label=lst:my_listing,language=C++]
  std::cout << "Hello World!" << std::endl;
\end{lstlisting}
\cleardoublepage

\lstlistoflistings
\addcontentsline{toc}{chapter}{Listings}
\thispagestyle{empty}
\cleardoublepage

\end{document}

verwandte Informationen