Page Layout\pagestyle{fancy} gives an error

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
komal
Posts: 14
Joined: Thu Jun 02, 2011 1:57 pm

\pagestyle{fancy} gives an error

Post by komal »

I'm trying to add headers to my document but it gives an error right where I include the command \pagestyle{fancy}
The error is :

Missing = inserted for \ifdim
<to be read again>
&
\pagestyle{fancy}

Here's the code:

Code: Select all

\documentclass[pdftex,12pt,a4paper]{report}                                
\usepackage{url}                                                           
\usepackage{subfigure}                                                     
                                                                           
\usepackage[top=1.5in, bottom=1in, left=1.5in, right=1in]{geometry}        
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}                              
\usepackage[pdftex]{graphicx}                                              
\usepackage{fancyhdr}                                                      
\pagestyle{fancy}                                                          



Last edited by komal on Wed Jun 08, 2011 8:46 pm, edited 1 time in total.

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Re: \pagestyle{fancy} gives an error

Post by Stefan Kottwitz »

Hi komal,

welcome to the board!

This code example doesn't produce that error, the problem is somewhere else. Please provide a complete example.

Stefan
LaTeX.org admin
komal
Posts: 14
Joined: Thu Jun 02, 2011 1:57 pm

Re: \pagestyle{fancy} gives an error

Post by komal »

What could be the possible reason. The code itself is quite long and I'm not sure how to mention it here. Can there be an issue with keeping the fanchdr package in a wrong folder though the error is only related to \pagestyle{fancy}

In my document I've used titlpage, chapters and sections. Could there be an issue with that?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

\pagestyle{fancy} gives an error

Post by Stefan Kottwitz »

You don't need to post your complete document. Create a copy of the document, and reduce it - remove text which is not part of the problem.

Often the preamble together with some dummy chapter resp. text could be sufficient, and even the preamble can be reduced, removing not relevant packages.

This text is helpful: What is a minimal working example. It may seem to be laborious, but a working example is usually a guarantee for getting a solution.

Stefan
LaTeX.org admin
komal
Posts: 14
Joined: Thu Jun 02, 2011 1:57 pm

\pagestyle{fancy} gives an error

Post by komal »

Code: Select all

\documentclass[pdftex,12pt,a4paper]{report}                                    
\usepackage{url}                                                               
\usepackage{subfigure}                                                                                                                                      \usepackage[top=1.5in, bottom=1in, left=1.5in, right=1in]{geometry}            
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}                                  
\usepackage[pdftex]{graphicx}                                                  
\usepackage{fancyhdr}                                                          
\pagestyle{fancy}                                                              
                                                                                                                                                              \begin{document}                                                               
                                                                               
\newpage                                                                       
\thispagestyle{empty}                                                          
\mbox{}                                                                        
                                                                                                                                                            
\begin{titlepage}                
\begin{center}                                                                           
\LARGE text \\[0.8cm]                   
\Large tex\\[1.5cm]                                                                                                                              
\HRule \\[0.4cm]                                                                         
{\LARGE\bf text}\\                     
\HRule \\[1.4cm]                                                                         
                                                                                         
\begin{minipage}{0.4\textwidth}                                                          
\begin{flushleft} \large                                                                         

\end{flushleft}              
\end{minipage}               
\begin{minipage}{0.4\textwidth}
\begin{flushright} \large    
\emph{text} \\        

\end{flushright}             
\end{minipage}               
 \end{center}                 
\end{titlepage}            


\newpage                         
\begin{flushleft}                
    \textbf{\large Abstract}     
\end{flushleft}                  


\tableofcontents
\chapter{Introduction}
\section{text}

\bibliographystyle{plain}       
\bibliography{ref}              
                                
\end{document}                  
                                  

                                      
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

\pagestyle{fancy} gives an error

Post by Stefan Kottwitz »

Does exactly this example gives the error?
Because when I compile it there's no error.

Stefan
LaTeX.org admin
komal
Posts: 14
Joined: Thu Jun 02, 2011 1:57 pm

Re: \pagestyle{fancy} gives an error

Post by komal »

yes it's the exact example. :?
Could there be something wrong with the installation of .sty file ?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Re: \pagestyle{fancy} gives an error

Post by Stefan Kottwitz »

Possibly! Please include the command \listfiles in your preamble, compile again and post the produced .log file here as attachment to a post.

Stefan
LaTeX.org admin
komal
Posts: 14
Joined: Thu Jun 02, 2011 1:57 pm

Re: \pagestyle{fancy} gives an error

Post by komal »

I have also used \subsection and \subsubsection commands in the file ( if that helps)
Attachments
report.log
(2.78 KiB) Downloaded 475 times
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

\pagestyle{fancy} gives an error

Post by Stefan Kottwitz »

Your packages are located in C:\Program Files\MiKTeX 2.5\tex\latex, perhaps not fancyhdr? Is it in your document directory? If yes, move it away or rename it and test again, I would use fancyhdr of MiKTeX.

By the way, your MiKTeX installation 2.5 is very old (2006) and no longer supported, the current version is MiKTeX 2.9.

Stefan
LaTeX.org admin
Post Reply