Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to set two different layouts (namely headers) for my document. The document is two column dictionary. First part will be introduction with chapters and sections and the second part the dictionary itself where the headers are made from the first and the last headword on the page. I dont know how to set the first layout with chapter in header and than how to change it to different layout. Here is the code:

\documentclass[twocolumn]{book}
\usepackage[top=2cm, bottom=2cm, left=2cm, right=2cm]{geometry}
\usepackage{fancyhdr}
\usepackage[icelandic, czech, english]{babel}
\usepackage[utf8x, utf8]{inputenc}
\newcommand{\entry}[2]{\hangpara{2em}{1}\textsf{\textbf{#1}}\ #2\markboth{#1}{#1}\par}\nopagebreak[4]
\pagestyle{fancy}
\newcommand*{\dictchar}[1]{\centerline{\LARGE\textbf{#1}}\par}
\fancyhf{}
\fancyhead[LE,RO]{\textsf{\textbf{\rightmark\ -- \leftmark}}}
\fancyhead[LO,RE]{\textsf{\textbf{\thepage}}}
\usepackage{fix2col}
\begin{document}\maketitle
\thispagestyle{plain}
\chapter*{1. First chapter}
\section*{1.1 First section}
...
share|improve this question

migrated from stackoverflow.com Oct 27 '11 at 12:39

This question came from our site for professional and enthusiast programmers.

    
Welcome to TeX.sx! Please reduce your code to a minimal working example (MWE) that illustrates your problem. –  N.N. Oct 27 '11 at 12:41
add comment

1 Answer

up vote 4 down vote accepted

You could use the command \fancypagestyle for defining your header layouts. The first argument is the name of your layout, the second argument contains the commands you would like to apply. Afterwards you can choose any of those custom layouts by \pagestyle and \thispagestyle.

Example:

\documentclass{book}
\usepackage{fancyhdr}
\fancypagestyle{basicstyle}{%
  \fancyhf{}
  \fancyhead[LE,RO]{\rightmark}
  \fancyhead[LO,RE]{\leftmark}
  \fancyfoot[C]{\thepage}
  \renewcommand{\headrulewidth}{0.4pt}
  \renewcommand{\footrulewidth}{0pt}}
\fancypagestyle{otherstyle}{%
  \fancyhf{}
  \fancyhead[C]{header}
  \renewcommand{\headrulewidth}{0pt}}
\pagestyle{basicstyle}
\begin{document}
\chapter{One}
\section{First section}
\thispagestyle{otherstyle}
\clearpage
text
\end{document}
share|improve this answer
    
Problem is now that there comes to the first layout the headwords (that should appear in the second layout) - probably from \newcommand{\entry}[2]{\hangpara{2em}{1}\textsf{\textbf{#1}}\ #2\markboth{#1}{#1}\par}\nopagebreak[4] command. Should I place this command to the propriet fancypagestyle? –  chejnik Oct 28 '11 at 8:00
    
@chejnik I suggest, post a new question with your current code (compilable small demo example) and your \fancypagestyle settings. –  Stefan Kottwitz Oct 28 '11 at 8:48
    
Ok, thank you for an advice –  chejnik Oct 28 '11 at 9:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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