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.

This is how my page looks:

enter image description here

What I want to do is, add a header to the blackened portion in this image:

enter image description here

These are the settings that I am already using:

\documentclass[letter, 10pt]{report}\normalsize
\usepackage{amsmath,utopia}
\usepackage{titlesec}
\usepackage{graphicx}
\usepackage{geometry}
\usepackage{epsfig}
\usepackage[hidelinks]{hyperref}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{setspace}
\usepackage{footnote}
\usepackage{rotating}
\usepackage{needspace}
\makesavenoteenv{tabular}
\textwidth 7.5in
\addtolength{\oddsidemargin}{-0.75in}
\textheight 9.5in
\pagestyle{plain}
\addtolength{\topmargin}{-0.75in}
\setlength{\parindent}{0pt}
\setlength{\parskip}{0.73cm}
\topskip 0in
\usepackage{tabularx}
\usepackage{fancybox}
\newenvironment{boxedlaw}[1]
  {\begin{Sbox}\begin{minipage}{#1}\centering}
  {\end{minipage}\end{Sbox}\begin{center}\fbox{\TheSbox}\end{center}}
\usepackage{cutwin}
\opencutright


\usepackage{background}
\usepackage{lipsum}
\usetikzlibrary{calc}

\SetBgScale{1}
\SetBgAngle{0}
\SetBgColor{brown}
\SetBgContents{
\begin{tikzpicture}[overlay,remember picture]
    \draw [line width=3pt,rounded corners=0pt]
        ($ (current page.north west) + (0.4in,-0.4in) $)
        rectangle
        ($ (current page.south east) + (-0.4in,0.4in) $);
\end{tikzpicture}
}

\usepackage{listings}
\usepackage{xcolor}

\definecolor{mycolor}{HTML}{F8E0E0}

\titleformat{\chapter}[display]
  {\normalfont\bfseries\LARGE}
  {\chaptertitlename~\thechapter}{0.5pc}
  {{\color{brown}\titlerule[2pt]}\vspace{0.1pc}\MakeUppercase}
\titleformat{name=\chapter,numberless}[display]
  {\normalfont\bfseries\LARGE}{}{0.5pc}
  {\MakeUppercase}

The header will be some static text. Not section names or page numbers. However I want it to start from the point I want. That is, I dont want that header on the first few pages. And I want it on every page after that. Is there a simple way to do it?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Here I want to propose another solution, using the titleps package; the basic idea is to define a new page style which I called special; using \pagestyle{special} this new page style can be activated; since you also want to include the special text in the first page of some chapter(s), a redefinition of the plain style is also needed. Using \begingroup, \endgroup, the changes can be kept local (so you can apply the new style only to some page(s)). The code:

\documentclass[letterpaper, 10pt]{report}
\usepackage{amsmath,utopia}
\usepackage{titlesec}
\usepackage{graphicx}
\usepackage{geometry}
\usepackage{epsfig}
\usepackage[hidelinks]{hyperref}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{setspace}
\usepackage{footnote}
\usepackage{rotating}
\usepackage{needspace}
\makesavenoteenv{tabular}
\textwidth 7.5in
\addtolength{\oddsidemargin}{-0.75in}
\textheight 9.5in
\pagestyle{plain}
\addtolength{\topmargin}{-0.75in}
\setlength{\parindent}{0pt}
\setlength{\parskip}{0.73cm}
\topskip 0in
\usepackage{tabularx}
\usepackage{fancybox}
\newenvironment{boxedlaw}[1]
  {\begin{Sbox}\begin{minipage}{#1}\centering}
  {\end{minipage}\end{Sbox}\begin{center}\fbox{\TheSbox}\end{center}}
\usepackage{cutwin}
\opencutright


\usepackage{background}
\usepackage{lipsum}
\usetikzlibrary{calc}

\SetBgScale{1}
\SetBgAngle{0}
\SetBgColor{brown}
\SetBgContents{
\begin{tikzpicture}[overlay,remember picture]
    \draw [line width=3pt,rounded corners=0pt]
        ($ (current page.north west) + (0.4in,-0.4in) $)
        rectangle
        ($ (current page.south east) + (-0.4in,0.4in) $);
\end{tikzpicture}
}

\usepackage{listings}
\usepackage{xcolor}

\definecolor{mycolor}{HTML}{F8E0E0}

\titleformat{\chapter}[display]
  {\normalfont\bfseries\LARGE}
  {\chaptertitlename~\thechapter}{0.5pc}
  {{\color{brown}\titlerule[2pt]}\vspace{0.1pc}\MakeUppercase}
\titleformat{name=\chapter,numberless}[display]
  {\normalfont\bfseries\LARGE}{}{0.5pc}
  {\MakeUppercase}

\usepackage{lipsum}% just for the example
\usepackage{titleps}

% command to store the fixed text that will go in the header
\newcommand\SpecialText{\raisebox{-1em}{Some fixed text}}

% definition of the new special page style to include the fixed text
\newpagestyle{special}
  {\sethead{}{}{\SpecialText}\setfoot{}{\thepage}{}}

\begin{document}


\begingroup% to keep the change local
\pagestyle{special}
% since the first page of a chapter internally uses the plain page style
% we locally redefine this style to include the fixed text
\renewpagestyle{plain}
  {\sethead{}{}{\SpecialText}\setfoot{}{\thepage}{}}
\chapter{Test Chapter}
\lipsum[1-20]
\endgroup% to keep the change local

\chapter{Test Chapter}
\lipsum[1-20]

\end{document}

And an image showing the special text in the first page of a chapter:

enter image description here

If you want to apply the special style to a single page different from the first page of a chapter, you can simply invoke

\thispagestyle{special}

somewhere in the material that will go in that page.

share|improve this answer
    
The problem I have when I use this is, this new pagestyle removes the page numbering on the page where a particular chapter starts. I want the page numbers to be displayed too. Also is there anything I can do to make sure that the text I write on the top right corner can be made to touch the upper margin? –  Karan Thakkar Apr 19 '12 at 9:10
    
@HarishKumar, I tried your way but I dont get anything. I dont understand. It displays the page as it was earlier. –  Karan Thakkar Apr 19 '12 at 9:12
    
@KaranThakkar: see my updated answer. –  Gonzalo Medina Apr 19 '12 at 12:16
    
I get the page numbers now. No sweat. But another problem has come up. I dont know why but after page 45 in my manuscript the header text just stops appearing. Is there a page limit till which this solution works? This is the tex file. I did not know what code to include so you can see for yourself. db.tt/v2H1F2fB –  Karan Thakkar Apr 19 '12 at 19:53
1  
@KaranThakkar: you have an "intruding" flushleft environment; carefully delete (or comment out) the \begin{flushleft} (aprox. on line 177) and the \end{flushleft} (aprox. on line 1107), and reprocess your document. –  Gonzalo Medina Apr 19 '12 at 22:06

Your code is not complete and minimal. However, the feature requested can be achieved fancyhdr:

\documentclass{article}
\usepackage{tikz}
\usepackage{lipsum} %<-----provides dummy text, remove in your file
\usepackage{fancyhdr}
\usepackage[a4paper,margin=1in,showframe]{geometry} % <-----remove showframe and alter other things in your file
%---------------------------------------------
\fancypagestyle{mystyle}{%
\fancyhf{}   % Clear all headers and footers first
\fancyhead[L]{}
\fancyhead[R]{%
\begin{tikzpicture}[remember picture,overlay]
\node[draw=brown,very thick,outer color=magenta!30,inner color=white, rectangle, rounded corners=.3cm] at ([xshift=-4.5cm,yshift=-2cm]current page.north east) {My text comes here};
\end{tikzpicture}
}%
%\setlength{\headsep}{1.1in} % if needed you can change this value
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
}%
%Change the values in xshift and yshift as per your needs
%---------------------------------------------
\begin{document}
\lipsum[1-5]
\newpage
\pagestyle{mystyle}
\lipsum[6-8]
\end{document}

The pages with no header:

enter image description here

Pages with header:

enter image description here

You may tweak this style to suit your text and taste.

share|improve this answer

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.