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.

the line is longer than the width of the text, how do I adjust, knowing that the package needs fanchyhdr geometry?

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage{preambulo}
%Configuracao de pagina
\geometry{paperwidth=18cm,paperheight=24cm,lmargin=3cm,rmargin=3cm,tmargin=3cm,bmargin=3cm}
\usepackage[a4,center,cam]{crop}
\usepackage{hyperref}
\hypersetup{pdfpagelayout=TwoPageLeft, %SinglePage
  bookmarksopen=true,
  colorlinks=true,
  urlcolor=blue,
  linkcolor=black,
  pdftitle={titulo},
  pdfauthor={R\'egis S. Santos}
}

\newcommand{\titulo}{Book}
\title{\titulo}
\author{R\'egis S. Santos}
\date{\the\year}

\makeindex
\begin{document}
\pagestyle{fancy}
\frontmatter   %book
\maketitle
\tableofcontents
\mainmatter    %book

%texto
\chapter{Book}
\label{chap_Book}

\lipsum[1-5]

\end{document}

and preambulo.sty

%Preambulo geral -2011
\usepackage[brazil]{babel}
\usepackage{amssymb,amsfonts,indentfirst}
\usepackage[centertags]{amsmath}
\usepackage[normalem]{ulem}
\usepackage{enumerate,multicol,subfigure,cancel,makeidx}
\usepackage{tikz}
  \usetikzlibrary{calc,positioning}
\usepackage{wasysym,mathrsfs,stmaryrd}
\usepackage{geometry,lipsum}
%%força um \pagestyle{empty} em \part
\usepackage{etoolbox}
  \patchcmd{\part}{plain}{empty}{}{}
%********************************************************************
\everymath{\displaystyle}
%********************************************************************
% Configuracao de ambiente de teorema
% a numeracao do teorema depende da classe de documento
\usepackage{theorem}

\newcommand*{\teorema}[1][chapter]{
  \newtheorem{teo}{Teorema}[#1]
  \theorembodyfont{\normalfont\upshape}
  \newtheorem{ex}{Exemplo}[#1]
  \newtheorem{exerc}{}[#1]
  \newtheorem{cor}[teo]{Corol\'ario}
  \newtheorem{lem}[teo]{Lema}
  \newtheorem{prop}[teo]{Proposi\c{c}\~ao}
  \newtheorem{axi}[teo]{Axioma}
  \newtheorem{fato}[teo]{Fato}
  \theorembodyfont{\normalfont\upshape}
  \newtheorem{defn}[teo]{Defini\c{c}\~ao}
}
%********************************************************************
% Configuracao de cabecalho personalizado
\usepackage{fancyhdr}
\pagestyle{fancy}

\newcommand*{\BookHeader}[1]{%
  %%teoremas
  \teorema  %if book
  %%cabecalho e rodape
  \fancyhead{} % deleta a configuração atual para cabeçalho.
  %redefine para que apareça apenas o nº do capitulo.
  \renewcommand{\chaptermark}[1]{\markboth{\thechapter.\space##1}{}}
  \renewcommand{\sectionmark}[1]{\markright{\thesection\space##1}}
  %evenside - lado par
  %oddside - lado impar
  \fancyhead[LE]{\bfseries\leftmark}  %capitulo do lado esquerdo na pag. par.
  \fancyhead[RO]{\bfseries\rightmark} %seção do lado direito na pag. impar.
  \fancyfoot{} % deleta a configuração atual para rodapé.
  \fancyfoot[LE,RO]{\bfseries\thepage}   %nº da pagina do lado direito e no rodapé.
  \fancyfoot[C]{\scriptsize{\titulo}}
  \fancyfoot[LO,RE]{R\'egis {\Large \smiley} \the\year}
  \renewcommand{\headrulewidth}{0.5pt}
  \renewcommand{\footrulewidth}{0.5pt}
  \addtolength{\headheight}{12.5pt} % cria espaço para a linha
  \fancypagestyle{plain}{%
  \fancyhead{} % exibe o cabeçalho e o rodapé
  \renewcommand{\headrulewidth}{0pt} % e a linha
  }
  \typeout{Using book class.}%
}%

\newcommand*{\ArticleHead}[1]{%
  %%teoremas
  \teorema[section] % if article
  %%cabecalho e rodape
  \fancyhead{}
  \fancyfoot{}
  \fancyfoot[R]{\bfseries\thepage}   %nº da pagina do lado direito
  \fancyfoot[C]{\scriptsize{\titulo}}
  \fancyfoot[L]{R\'egis {\Large \smiley} \the\year}
  \renewcommand{\headrulewidth}{0pt}
  \renewcommand{\footrulewidth}{0.5pt}
  \addtolength{\headheight}{0.5pt}
  \fancypagestyle{plain}{%
  \fancyhead{}
  \renewcommand{\headrulewidth}{0pt}
  }
  \typeout{Using article class.}%
}%

\newcommand*{\ReportHead}[1]{%
  %%teoremas
  \AfterPreamble{\teorema}  %if report
  %%cabecalho e rodape
  \fancyhead{}
  \renewcommand{\chaptermark}[1]{\markboth{\thechapter.\space##1}{}}
  \renewcommand{\sectionmark}[1]{\markright{\thesection\space##1}}
  \fancyhead[L]{\bfseries\leftmark}  %capitulo do lado esquerdo
  \fancyhead[R]{\bfseries\rightmark} %seção do lado direito
  \fancyfoot{}
  \fancyfoot[R]{\bfseries\thepage}   %nº da pagina do lado direito
  \fancyfoot[C]{\scriptsize{\titulo}}
  \fancyfoot[L]{R\'egis {\Large \smiley} \the\year}
  \renewcommand{\headrulewidth}{0.5pt}
  \renewcommand{\footrulewidth}{0.5pt}
  \addtolength{\headheight}{12.5pt}
  \fancypagestyle{plain}{%
  \fancyhead{}
  \renewcommand{\headrulewidth}{0pt}
  }
  \typeout{Using report class.}%
}%

\makeatletter%
\newcommand*{\SetHeaders}[1]{%
    \@ifclassloaded{book}{\BookHeader{#1}%
    }{\@ifclassloaded{article}{\ArticleHead{#1}%
    }{\@ifclassloaded{report}{\ReportHead{#1}}{%
      \typeout{Error: Unsupported class: 'article' or 'report' or 'book' are suported.}
    }}}%
}%
\makeatother%

\SetHeaders{foo}%
%********************************************************************
% Ambiente para demonstração que coloca quadrado no final, usando \rule
% Nota: \rule{largura}{altura} produz um retagulo preto.
\newenvironment{dem}[1][Demonstração]{\textbf{#1:}\

}  {\hfill\rule{1ex}{1ex}}

% Ambiente para resolução de exercícios. Não juntar!
\newenvironment{sol}[1][Solução]{\uline{#1}:\

}  {\hfill $\Box$}  %O espaço provoca uma mudança de parágrafo no texto.
share|improve this question
    
When compiling your not-so-MWE document, the fancyhdr line is just as long as \textwidth. Its width (\headrulewidth) is 0pt (non-existent) on plain pages, and 0.5pt on all other pages. What TeX distribution are you using? Some coding style suggestions: lmargin=3cm,rmargin=3cm,tmargin=3cm,bmargin=3cm is equivalent to margin=3cm. Your command \SetHeaders does not require an argument. So use \newcommand*{\SetHeaders}{...} dropping the [1] and call \SetHeaders (not \SetHeaders{foo}). –  Werner Aug 12 '11 at 20:08
add comment

1 Answer

up vote 3 down vote accepted

Call geometry before preambulo.sty, so that fancyhdr will know about the correct text width.

share|improve this answer
    
You're right. I compiled the document on [ScribTeX](www.scibtex.com), so I just copied/pasted preambulo.sty into the document preamble after geometry, and also changed \geometry{...} to \usepackage[...]{geometry}. –  Werner Aug 12 '11 at 22:18
    
Thanks egreg and Werner. –  Regis da Silva Aug 13 '11 at 2:26
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.