如何在页眉中获取作者、标题和章节标题(示例 1. 简介)以及在页脚右侧获取页码。
\documentclass[a4paper,12pt]{report}
\usepackage{geometry}
\geometry{margin=2.00cm}
\usepackage{pdfpages}
\usepackage{dirtytalk}
\usepackage{fancyhdr}
\usepackage{newcent}
\usepackage{setspace}
\usepackage{epigraph}
\usepackage{csvsimple}
\usepackage{sectsty}
\allsectionsfont{\sffamily}
%\singlespacing
\onehalfspacing
\newtheorem{hypothesis}{Hypothesis}
\newtheorem{nullhypothesis}{Null Hypothesis}
\usepackage[linktoc=all]{hyperref}
\hypersetup{
colorlinks = true, % Colours links instead of ugly boxes
urlcolor = black, % Colour for external hyperlinks
linkcolor = black, % Colour of internal links
citecolor = red % Colour of citations
}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{natbib}
\usepackage{amsmath}
\usepackage[font={small,it}]{caption}
\addto\captionsenglish{\renewcommand{\figurename}{Fig.}}
%images
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage[export]{adjustbox}
\newcommand\cites[1]{\citeauthor{#1}'s\ (\citeyear{#1})}
%\captionsetup{justification=raggedright,singlelinecheck=false}
\usepackage{booktabs}
\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}
\usepackage{bchart}
\usepackage{pgfplots}
\usepackage{todonotes}
\title{xx}
\author{xx}
\pagestyle{fancy}
\lhead{\author{xxx}}
\chead{\title{xx}
\rhead{\leftmark}
\renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{#1}}{}}
%put chapter and title on same line
\usepackage{titlesec}
\titleformat{\chapter}[hang]
{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter:}{1em}{}
\begin{document}
\maketitle
\tableofcontents
\listoffigures
\listoftables
\include{introduction}
\chapter{Appendix}
\bibliography{sources}
\bibliographystyle{apalike}
\end{document}
答案1
这是一个基于titleps
和 的解决方案titling
,它定义了命令\theauthor
和\thetitle
以供以后使用。由于您加载titlesec
它,因此只需添加[pagestyles]
选项即可:
\documentclass[a4paper,12pt,english]{report}
\usepackage{geometry}
\geometry{margin=2.00cm}
\usepackage{pdfpages}
\usepackage{dirtytalk}
\usepackage{newcent}
\usepackage{setspace}
\usepackage{epigraph}
\usepackage{csvsimple}
\usepackage{sectsty}
\allsectionsfont{\sffamily}
%\singlespacing
\onehalfspacing
\newtheorem{hypothesis}{Hypothesis}
\newtheorem{nullhypothesis}{Null Hypothesis}
\usepackage[linktoc=all]{hyperref}
\hypersetup{
colorlinks = true, % Colours links instead of ugly boxes
urlcolor = black, % Colour for external hyperlinks
linkcolor = black, % Colour of internal links
citecolor = red % Colour of citations
}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{natbib}
\usepackage{amsmath}
\usepackage[font={small,it}]{caption}
\addto\captionsenglish{\renewcommand{\figurename}{Fig.}}
%images
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage[export]{adjustbox}
\newcommand\cites[1]{\citeauthor{#1}'s\ (\citeyear{#1})}
%\captionsetup{justification=raggedright,singlelinecheck=false}
\usepackage{booktabs}
\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}
\usepackage{bchart}
\usepackage{pgfplots}
\usepackage{todonotes}
\usepackage{titling}
\title{Ventriloquist Cat}
\author{TeX Avery}
\keepthetitle
%put chapter and title on same line, and use titleps for headers and footers
\usepackage[pagestyles]{titlesec}
\titleformat{\chapter}[hang]
{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter:}{1em}{}
\makeatletter
\newpagestyle{mystyle}{%
\headrule
\sethead{\author{TeX Avery}}{\title{Ventriloquist Cat}}{\thechapter.~\MakeUppercase{\chaptertitle}}
\setfoot{}{}{\thepage} }%
\makeatother
\renewpagestyle{plain}{%
\setfoot{}{}{\thepage}}
\pagestyle{mystyle}
\usepackage{lipsum}
\begin{document}
\maketitle
\tableofcontents
\listoffigures
\listoftables
\chapter{introduction}
\lipsum
\chapter{Appendix}
\lipsum
\bibliography{sources}
\bibliographystyle{apalike}
\end{document}