GeneralDocument Title in Header

LaTeX specific issues not fitting into one of the other forums of this category.
EnWor
Posts: 4
Joined: Sun Oct 05, 2008 2:07 am

Document Title in Header

Post by EnWor »

Hello,

How can i insert the Author or Title into the Header?
In my solution I have to write the Name of the Author two times... how can i insert the \author name into the Header?

Greetings
EnWor

\documentclass[12pt,a4paper,twoside]{article}
\usepackage[automark,headsepline,plainheadsepline]{scrpage2}

\newcommand{\TheAuthor}{}
\newcommand{\Author}[1]{\renewcommand{\TheAuthor}{#1}}

\ihead{\TheAuthor}
\pagestyle{scrheadings}

\title{something}
\Author{Mustermann}
\author{Mustermann}

\begin{document}

\maketitle
\thispagestyle{empty}

\pagebreak

blabla

\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Document Title in Header

Post by gmedina »

Hi EnWor,

you could use \markboth or \markright (some information about these commands can be found here), toghether with \@author (for the author) and \@title (for the title), as the following example suggests:

Code: Select all

\documentclass[12pt,a4paper,twoside]{scrartcl}
\usepackage[headsepline,plainheadsepline]{scrpage2}

\title{something}
\author{Mustermann}

\makeatletter
  \markboth{\@title}{\@author}
\makeatother

\pagestyle{scrheadings}

\begin{document}

\maketitle
\thispagestyle{empty}

\newpage

blabla

\newpage

blabla
\end{document}
I took the liberty to change the original document class from article to scrartcl (from the KOMA-Script bundle). This is only a suggestion.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
EnWor
Posts: 4
Joined: Sun Oct 05, 2008 2:07 am

Document Title in Header

Post by EnWor »

Juhu, It works, thx ;)

But now i have another problem...

I used the \ihead command because in my document i put the section with:

Code: Select all

\automark[section]{section}
\ohead[\headmark]{\headmark}
... into the Header
With Markboth this doesn't work... :(

Any Solution?
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Re: Document Title in Header

Post by gmedina »

Hi,

can you please describe exactly what information and in what positions should appear in your headers? That will save us time and effort.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
EnWor
Posts: 4
Joined: Sun Oct 05, 2008 2:07 am

Re: Document Title in Header

Post by EnWor »

oke... sry

In my twoside document I wand in the inner header the documenttitle, in the outer Header the sectiontitle and in the outer footer the page Number...

I hope this is exact enough... if not ask me..

so long
thanks a lot
EnWor
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Document Title in Header

Post by gmedina »

Hi,

then you could use something like the following:

Code: Select all

\documentclass[12pt,a4paper,twoside]{scrartcl}
\usepackage[headsepline,plainheadsepline]{scrpage2}
\usepackage{lipsum}%just to generate some text

\title{something}
\author{Mustermann}

\automark[section]{section}
\ihead{\@title}
\pagestyle{scrheadings}

\begin{document}

\maketitle
\thispagestyle{empty}

\section{First section}
\lipsum[1-30]

\section{Second section}
\lipsum[1-30]

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

Document Title in Header

Post by Stefan Kottwitz »

Hi,
gmedina wrote:

Code: Select all

\ihead{\@title}
this will not work like expected. This code should to it:

Code: Select all

\newcommand*\mytitle{something}
\title{\mytitle}
\ihead{\mytitle}
Stefan
LaTeX.org admin
EnWor
Posts: 4
Joined: Sun Oct 05, 2008 2:07 am

Re: Document Title in Header

Post by EnWor »

Juhu ;))

Thx you... It work's like I wished ;)

Thank's a lot
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Document Title in Header

Post by gmedina »

Hi Stefan,
Stefan_K wrote:Hi,
gmedina wrote:

Code: Select all

\ihead{\@title}
this will not work like expected...
Did you compile the complete code I posted? It works OK (at least it does on my system). Maybe I misunderstand your comment, but what do you mean when you say that "it will not work as expected"?
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

Document Title in Header

Post by Stefan Kottwitz »

Hi gmedina,

yes, I've compiled your code, instead of something the word title appeared in the output, arising from \@title.

Stefan
LaTeX.org admin
Post Reply