我尝试在每页的页眉中显示节名称。但是,它在编译时没有显示。
我想将章节名称显示为简介、测试 1 和测试 2(仅示例章节)的标题。我尝试实现此目的的具体代码是\fancyhf{} \fancyhead[L]{\leftmark}
\documentclass[table,xcdraw,a4paper,12pt]{article}
\setcounter{tocdepth}{4}
\setcounter{secnumdepth}{4}
% Importing document settings from our file "packages.sty"
\usepackage{packages}
\usepackage{appendix}
\usepackage{minted}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{pdfpages}
\usepackage{titlesec}
\usepackage{listings}
\usepackage{multicol}
\usepackage{xcolor}
\usepackage{multirow}
\usepackage{amssymb}
\usepackage{color} %red, green, blue, yellow, cyan, magenta, black, white
\definecolor{mygreen}{RGB}{28,172,0} % color values Red, Green, Blue
\definecolor{mylilas}{RGB}{170,55,241}
\usepackage[utf8]{inputenc}
\usepackage[toc]{glossaries}
\usepackage{comment}
\makeglossaries
\setcounter{secnumdepth}{4}
\titleformat{\paragraph}
{\normalfont\normalsize\bfseries}{\theparagraph}{1em}{}
\titlespacing*{\paragraph}
{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\usepackage[paper=a4paper,left=25mm,right=25mm,top=25mm,bottom=25mm]{geometry}
\setlength{\parindent}{0em}
\setlength{\parskip}{0.8em}
\renewcommand{\baselinestretch}{1.1}
% Customized header and footer
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{\leftmark} %added
\renewcommand{\headrulewidth}{0.1ex}
\renewcommand{\footrulewidth}{0.1ex}
\fancyfoot[C]{\thepage}
\begin{document}
%Insert the coverpage
%\import{./}{Coverpage}
%\import{./Sections/}{Preface}
%\thispagestyle{empty}
% Inserting title page
%\import{./}{title}
\pagestyle{empty}
\import{./Sections/}{Sammendrag}
\thispagestyle{empty}
\pagestyle{plain}
\pagestyle{empty}
\import{./Sections/}{Abstract}
\thispagestyle{empty}
\pagestyle{plain}
\import{./Sections/}{Acknowledgements}
% Inserting table of contents
\pagestyle{empty}
\tableofcontents
\thispagestyle{empty}
\pagestyle{plain}
\numberwithin{equation}{section}
\numberwithin{figure}{section}
\numberwithin{table}{section}
%\import{./Sections/}{Acknowledgements}
%\import{./Sections/}{Abstract}
\import{./Sections/}{Introduction}
\import{./Sections/}{Test 1}
\import{./Sections/}{Test 2}