短章节标题和长章节标题

短章节标题和长章节标题

我想在目录中显示长章节标题,在标题中显示短标题(这意味着我不想在目录中显示短标题)。

\documentclass{report}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[LE,RO]{\normalsize\thepage}
\fancyhead[RE]{\footnotesize\itshape title}      
\fancyhead[LO]{\textcolor{black!90}{\footnotesize\itshape\leftmark}}
\renewcommand{\footrulewidth}{0.2pt}
\renewcommand{\headrulewidth}{0.2pt}
\usepackage[dvipsnames, table, svgnames]{xcolor}
\usepackage{lipsum}
\begin{document}
    \tableofcontents
    \chapter[Very long Very long Very long Very long  long long  long long  long]{Very long Very long Very long Very long Very long Very long Very long}
    \lipsum[1-2]
    \section{Long and short titles testing}
    \lipsum[1-2]
    \section{Long and short titles testing}
        \lipsum[1-2]
    \section{Long and short titles testing}
        \lipsum[1-2]
    \section{Long and short titles testing}
        \lipsum[1-2]
        \chapter[Very long long  long long  long long  long Very long Very long Very long  long]{Very long Very long Very long Very long Very long Very long Very long}
        \lipsum[1-2]
        \section{Long and short titles testing}
        \lipsum[1-2]
        \section{Long and short titles testing}
        \lipsum[1-2]
        \section{Long and short titles testing}
        \lipsum[1-2]
        \section{Long and short titles testing}
        \lipsum[1-2]
\end{document}

答案1

\chaptermark{Very short title chap. 1}之后使用\chapter

A

b

\documentclass{report}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[LE,RO]{\normalsize\thepage}
\fancyhead[RE]{\footnotesize\itshape title}      
\fancyhead[LO]{\textcolor{black!90}{\footnotesize\itshape\leftmark}}
\renewcommand{\footrulewidth}{0.2pt}
\renewcommand{\headrulewidth}{0.2pt}
\usepackage[dvipsnames, table, svgnames]{xcolor}
\usepackage{lipsum}
\begin{document}
    \tableofcontents
    
    \chapter[Very long Very long Very long Very long  long long  long long  long TOC 1]{Very short title chap. 1}
    \chaptermark{Very short title chap. 1} % for a short  header <<<<<<<<<<<<<<<
    \lipsum[1-2]
    \section{Long and short titles testing}
    \lipsum[1-2]
    \section{Long and short titles testing}
    \lipsum[1-2]
    \section{Long and short titles testing}
    \lipsum[1-2]
    \section{Long and short titles testing}
    \lipsum[1-2]
    \chapter[Very long long  long long  long long  long Very long Very long Very long  long TOC 2]{Very short title chap. 2}
    \chaptermark{Very short title chap. 2} % for a short  header <<<<<<<<<<<<<<<
    \lipsum[1-2]
    \section{Long and short titles testing}
    \lipsum[1-2]
    \section{Long and short titles testing}
    \lipsum[1-2]
    \section{Long and short titles testing}
    \lipsum[1-2]
    \section{Long and short titles testing}
    \lipsum[1-2]
\end{document}

你可能想尝试一下这个设置

\renewcommand{\chaptermark}[1]{\markboth{#1}{}} % remove Chapter xx from the header
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[LE,RO]{\normalsize\thepage}
\fancyhead[RE]{\footnotesize\itshape\nouppercase{Title of the report}} % use lower case    
\fancyhead[LO]{\textcolor{black!90}{\normalfont\footnotesize\itshape\nouppercase{\leftmark}}} % use lower case
\renewcommand{\footrulewidth}{0.2pt}
\renewcommand{\headrulewidth}{0.2pt}

相关内容