2

I am writing my thesis and I don't want to use any other headers except on the cover page, which is basically a title page. I use the scrreprt class. If I use the following code, I can clearly see that there is a section for headers, therefore I shouldn't have to create it, but only edit it somehow.

\documentclass[final,twoside,BCOR=0.7cm,DIV=calc,openright]{scrreprt}
\usepackage{showframe}
\begin{document}
    \pagenumbering{Roman}
    \begin{titlepage}
        I want this part in the header

        This in the body of the title page
    \end{titlepage}
\end{document}

I would rather not use the fancyhdr for two reasons:

  1. I feel like this is a very simple task and it shouldn't require a package. The header is already there and it has a 0 length text. I don't want to style the header in any way, so it feels like an overkill to use any package, nonetheless one which is named fancy
  2. I tried to use fancyhdr and I managed to add a header, but I had to use the \thispagestyle{fancy}, which adds page numbering on the titlepage. I imagine that there are solutions to remove the page number, but this would mean to fix a problem which I didn't have from the beginning.

The first googol pages on google about headers and latex are about how much fancy stuff you can do if you use fancyhdr. What if I don't want to be fancy, any solutions?

  • You can use a negative value for vspace (\vspace*{-2cm}) to move the text a bit up. It is a titlepage, which needs special care. showframe shows you the margins (and head) of normal pages. How to customize my titlepage? – Johannes_B Jul 30 '15 at 16:33
  • Thank you, I think that the \vspace*{-2cm} is what I'll use, but this feels more like a hack. Maybe there is an actual way to edit the actual heading. About showframe... you mean that the title page might not actually have a head section and showframe only prints the margins of the normal style? – Andrei Jul 30 '15 at 16:41
  • 1
    It is a titlepage, often they have a different set of margins than the rest of the document. Titlepages need special care and manually adjusting and placing stuff is normal. There are no hacks on title pages. ;-) – Johannes_B Jul 30 '15 at 17:35
  • btw, if you are interested: github.com/johannesbottcher/titlepages – Johannes_B Jul 31 '15 at 15:19
3
\documentclass[final,twoside,BCOR=0.7cm,DIV=calc,openright]{scrreprt}
\usepackage{showframe}
\begin{document}
    \pagenumbering{Roman}
    \begin{titlepage}
        \thispagestyle{headings}
        \markboth{I want this part in the header}{I want this part in the header}
        \def\thepage{}
        I want this part in the header

        This in the body of the title page
    \end{titlepage}

\end{document}
  • This adds numbering to the page, because it changes the style of the page, so it has the same problem as fancyhdr. Thanks, anyway! – Andrei Jul 30 '15 at 16:30
  • see edited answer – user2478 Jul 30 '15 at 16:41
  • this seems to work, thank you, but could you elaborate a bit what \def\thepage{} does actually do? – Andrei Jul 30 '15 at 16:46
  • It defines the output of the pagenumber to nothing, but only local to the titlepage – user2478 Jul 30 '15 at 16:57
  • while it is a solution that works, it is not what I expected. One of the reason's why I didn't want to use fancyhdr, as I explained in the question, is that it would add page numbering and then I would have to fix this problem, that I didn't have at the beginning. For now I will wait some more, to see if anyone has a solution that does exactly what I asked, meaning, editing the head section of the page, without modifying anything else. I understand that one of the reasons such a solution is hard to find is because it doesn't exist, but for now, let's see if other people have any more ideas – Andrei Jul 30 '15 at 17:31
2

If you want a header to be only on the cover page, then it is not a header at all. You could just include a text with altered font at the top of the page with desired alignment (XeLaTeX makes this a little easier for me).

  • Thank you, you are right, but because I was using showframe, I thought that the title environment has a reserved header space and I thought that I am supposed to use it, since it's there. Now I know better from @Johannes_B comment that showframe shows the frame for normal pages, even on the title page and the title page doesn't really have a any kind of header section in it, so I can simply just write some text and get it out of the text section by using a negative \vspace{-2cm} – Andrei Aug 6 '15 at 13:30
1

I think the answer of @Herbert solves your problem in a simple and good way.

If want a command that sets only a header on the current page you could load package scrlayer which is part of the KOMA-Script bundle and define a layer page style. But IMHO this is some kind of overkill to your problem.

\documentclass[final,twoside,BCOR=0.7cm,DIV=calc,openright]{scrreprt}
\usepackage{showframe}

\usepackage{scrlayer}
\DeclareNewLayer{header}
\newcommand*\thispageonlythisheader[1]{%
  \DeclareLayer[background,head,contents={#1}]{header}%
  \DeclarePageStyleByLayers{header}{header}%
  \thispagestyle{header}%
}

\usepackage{blindtext}

\begin{document}
\pagenumbering{Roman}
\begin{titlepage}
  \thispageonlythisheader{\hfill I want this part in the header}
  \blindtext
\end{titlepage}
\chapter{Chapter One}
\Blindtext
\chapter{Chapter Two}
\thispageonlythisheader{\hfill Here is also text in the header but nothing in the footer}
\Blindtext
\end{document}  
  • After a little bit more research about how things works in latex in general, I agree that @Herbert's answer matches my question as close as possible, so I'll have to mark that as an answer, but your answer is also interesting. – Andrei Jul 31 '15 at 12:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.