1

my problem is that I need a fancy style in the first page and an empty style in the rest. Even though I used \thispagestyle{fancy} only in the first page, it didn't work. Here's my code:

\documentclass{article}
\usepackage{eurosym}
\usepackage{enumerate}
\usepackage{fancyhdr}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage[spanish]{babel}
\usepackage{subfigure}
\usepackage{vmargin}
\usepackage{caption}
\usepackage{amsmath}

%Margins
\setpapersize{A4}
\setmargins{3.5cm} 
{2cm}     
{14.5cm}  
{23.42cm} 
{0pt}    
{1cm}   
{0pt}  
{2cm}  

%fancy
\renewcommand{\headrulewidth}{0pt} 
\lhead{\includegraphics[width = 0.45\textwidth]{image1}}
\rhead{\includegraphics[width = 0.16\textwidth]{image2}}
}

\begin{document}
    \title{Hello world}
    \author{author}
    \date{\empty}

    \maketitle

    \thispagestyle{fancy}

    bla bla bla bla bla bla bla bla bla %one page of text and images

    \newpage
    \thispagestyle{plain}
    bla bla bla bla bla

\end{document}

But the second page appears with no images in the header, neither page number in the foot and the top margin as if it had images in the header.

I hope I have been clear enough, otherwise, tell me and I'll edit the question. Thanks for your responses.

4
  • Can you make a compilable minimal working example (MWE) that included all packages necessary to compile it? Your above code results in several undefined commands and there are mismatched } Commented Dec 15, 2018 at 19:27
  • 1
    You have used round brackets in your \thispagestyle(plain) command, instead of curly brackets, e.g. \thispagestyle{plain}. Does fixing this help?
    – chrisma
    Commented Dec 15, 2018 at 19:31
  • Ok, I'll check it
    – Josemi
    Commented Dec 15, 2018 at 19:31
  • No, using brackets doesn't change anything, but I can include them in my code so that anyone else gets confused
    – Josemi
    Commented Dec 15, 2018 at 19:34

1 Answer 1

2

Prenotes:

  • It looks like you just want to add images to your title page. I would rather redefine the titlepage instead of creating a special page style for it

  • I would not use the vmargin package, it can interact badly with other packages. Rather have a look at the geometry package


If you want to make all following package have the plain pagestyle, use \pagestyle{plain} instead of \thispagestyle{}.

Also you code produces a warning that the headheight is too small and it automatically gets changed. You should set the headheight youself, you'll find the required value in the .log file. Because I used my own images, the value used in the example below probably won't work in your document. After the title page, you can switch the headheight again, e.g. to zero, if this is what you want.

\documentclass{article}
\usepackage{eurosym}
\usepackage{enumerate}
\usepackage{fancyhdr}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage[spanish]{babel}
\usepackage{subfigure}
\usepackage{vmargin}
\usepackage{caption}
\usepackage{amsmath}

%Margins
\setpapersize{A4}
\setmargins{3.5cm} 
{2cm}     
{14.5cm}  
{23.42cm} 
{0pt}    
{1cm}   
{0pt}  
{2cm}  

%fancy
\renewcommand{\headrulewidth}{0pt} 
\lhead{\includegraphics[width = 0.45\textwidth]{example-image}}
\rhead{\includegraphics[width = 0.16\textwidth]{example-image}}
\setlength{\headheight}{143pt} % <- change to whatever value the log file tells you

\begin{document}
    \title{Hello world}
    \author{author}
    \date{\empty}

    \maketitle

    \thispagestyle{fancy}

    bla bla bla bla bla bla bla bla bla %one page of text and images

    \newpage
        \pagestyle{plain}
        \setlength{\headheight}{0pt}


    bla bla bla bla bla

\end{document}

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .