2

I want more than one title for each topic in one document, I don't want to just combine two or three pdfs. And I want to show different headers starting from each title page. There's one problem I cannot solve.

I just used

\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{titling}
\pagestyle{fancy}
\setlength{\parindent}{0pt}
\setlength{\parskip}{8pt}
\setlength{\topmargin}{-0.5cm}
\setlength{\droptitle}{-1.5in}
\fancyhead{}
\lhead{Personal Statement}
\rhead{name}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0pt}
\title{Personal Statement}
\author{name}
\date{Oct 25 2013}
\begin{document}
\maketitle
 a lot of contents here
\title{Previous Projects and Future Plans}
\author{}
\date{}
\fancyhead{}
\lhead{Previous Projects and Future Plans}
\rhead{name}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0pt}
\maketitle
a lot of contents here
\end{document}

The titles can be displayed correctly, but headers cannot. The last page under the first title displayed the second header, I don't know why because my \lhead{} and \rhead{} are after the second \title. Hope someone can help.

I'm also wondering if it's formal to use \tile and \maketitle several times in one document? If not, is there any better way to do so? And could anybody tell me the scope of the typesetting macros at the beginning (\setlength, \lhead and so on)? I'm not sure how to limit their scope if they're meant to be applied to the whole contents of the document. Thanks a lot.

6
  • 1
    Welcome to TeX.SX! it is usually more helpful to include a complete minimal working example (MWE) in your question, as things like the document class also influence the layout of items such as headers.
    – mafp
    Oct 27, 2013 at 19:55
  • 1
    Please make your code compilable, starting with \documentclass{...} and ending with \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to help you. Help them help you: remove that one hurdle between you and a solution to your problem.
    – jub0bs
    Oct 27, 2013 at 19:58
  • A sketch of what you are willing to achieve would be helpfull too.
    – Crowley
    Oct 27, 2013 at 20:23
  • yeah, thanks very much. first time posting here, sorry Oct 28, 2013 at 4:26
  • You can't normally re-use commands like \author; but you can define your own. E.g.,: \newcommand{\theauthor}{} \newcommand{\Author}[1]{\renewcommand{\theauthor}[1]{#1}} and then 'set' the author each time with \Author{Yongfeng Zhang} and display it with \theauthor. The scope of \setlength is 'global' until re-set.
    – jon
    Oct 28, 2013 at 4:28

1 Answer 1

2

You need to clear the page (or rather \cleardoublepage) to get the headers right.

\documentclass{article}
\usepackage{fancyhdr}
\usepackage{blindtext}
\usepackage{showframe}
\pagestyle{fancy}
\fancyhead{}
\lhead{Personal Statement}
\rhead{name}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0pt}
\title{Personal Statement}
\author{name}
\date{Oct 25 2013}
\begin{document}
\maketitle
\blinddocument
\cleardoublepage%<- important
\title{Previous Projects and Future Plans}
\author{}
\date{}
\fancyhead{}
\lhead{Previous Projects and Future Plans}
\rhead{name}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0pt}
\maketitle
\blinddocument
\end{document}

But looking at the output of your document, it seems like to set chapter titles provided by a report or book class:

\documentclass{report}
\usepackage{fancyhdr}
\usepackage{blindtext}
\usepackage{showframe}
\pagestyle{fancy}
\fancyhead{}
\rhead{name}
\lhead{\leftmark}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0pt}
\title{Personal Statement}
\author{name}
\date{Oct 25 2013}
\begin{document}
\chapter{Personal Statement}
\blindtext[10]
\chapter{Previous Projects and Future Plans}
\blindtext[10]
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .