Document ClassesFootrule in Custom Class File

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
Gwind
Posts: 3
Joined: Fri Sep 13, 2013 7:48 pm

Footrule in Custom Class File

Post by Gwind »

Hi, folks.

I'm new to the forums and I'm writing a custom class based on article class. I would like to insert a rule in the footer along the text width, but the result of the code fraction below yields a rule with 3/4 text width length.

Code: Select all

\fancypagestyle{firstpage}{
  \fancyhf{} % clear all headers and footers
\headheight=1cm  %12pt normal
\headsep=2cm   %25pt normal
\fancyhead{}
  \fancyhead[CO]{\begin{tabular}{|c|>{\centering\arraybackslash}m{9.8cm}|c|c|}
\hline
\multirow{4}{*}{\parbox[c]{4em}{\includegraphics[width=1.6 cm, height=1.6 cm]{logo.png}}}
& \multirow{4}{*}{\parbox[c]{8cm}{\center\footnotesize\textbf{\@titulonit}}} & \footnotesize\textbf{NORMA N$^o$} &
\footnotesize\textbf{REV.
N$^o$} \\ 
 & & \footnotesize\textbf{NIT-\@divisao-\@nonorma} & \footnotesize\textbf{\@nrevisao} \\ \cline{3-4}
 & & \footnotesize\textbf{APROVADA} & \footnotesize\textbf{P\'AGINA} \\
 & & \footnotesize\textbf{\@dataaprov} & \footnotesize\textbf{\thepage/\pageref{LastPage}}\\ \hline
\end{tabular}}
\fancyfoot{}
%
\renewcommand{\footrulewidth}{0.4pt}
\renewcommand{\headrulewidth}{0pt}
}
Can anyone give me a hint to solve it? Help would be much appreciated!
Last edited by localghost on Sat Sep 14, 2013 11:10 am, 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.

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Footrule in Custom Class File

Post by cgnieder »

Hi Gwind,

Welcome to the LaTeX community!

Can you please make your code snippet into a full Infominimal working example, please?

Regards
site moderator & package author
Gwind
Posts: 3
Joined: Fri Sep 13, 2013 7:48 pm

Footrule in Custom Class File

Post by Gwind »

Hi Clemens!

Here goes the codes for the class and source files (MWEs). The class files is attached. Below is my source file (MWE).

Code: Select all

\documentclass[12pt,a4paper]{c2mwe}
\usepackage{enumitem}				% Cria listas numeradas
\usepackage[compact]{titlesec}			% Formato dos titulos
\usepackage[english,brazil]{babel}
\usepackage[utf8]{inputenc}			% Codificacao do arquivo
\usepackage{cmap}				% Mapear caracteres especiais no PDF
\usepackage[T1]{fontenc}			% Codificacao da fonte
\usepackage{amsmath,amssymb,amsfonts,textcomp}
\usepackage{setspace}	
\usepackage{lastpage}
\usepackage{parskip}
%.............................Layout...........................
\usepackage[top=3 cm, bottom=3.3 cm, left=1.5 cm, right=1.5 cm, footskip=0.5 cm]{geometry}
%........................Figuras................................
\usepackage[]{graphicx}				
\usepackage{color}				
\usepackage{subfig}				
%\graphicspath{{Figuras/}}			
\usepackage{caption}				
%\captionsetup[subfigure]{style=default, margin=0pt, parskip=0pt, hangindent=0pt, indention=0pt,
%singlelinecheck=true, labelformat=parens, labelsep=space}
%...........................Tabelas...............................
\usepackage{array}				
\usepackage{booktabs}				
\usepackage{longtable}				
\usepackage{lscape}				
%..........................Bibliografia..............................
\usepackage{natbib}										
%---------------------------------------------------
\begin{document}
%------------------------------------------------------Entrada de dados
\setor{XXXXX}		
%-----------------------------------------------------Entrada de dados
%
%%redefinindo o espa\c camento entre linhas do sum\'ario: sem espa\c co
\newcommand*{\noaddvspace}{\renewcommand*{\addvspace}[1]{}} 
\addtocontents{toc}{\protect\noaddvspace}
%% Determinando tamanhos de fontes para as secoes
\titleformat{\section}{\normalfont\small\bfseries\uppercase}{\thesection}{1em}{}
\titleformat{\subsection}{\normalfont\small\bfseries}{\thesubsection}{1em}{}
\titleformat*{\subsubsection}{\normalfont\small\bfseries}

\titlespacing*{\section}{0pt}{18pt}{10pt}[1pc] %espa\c cos para os titulos

\renewcommand*\contentsname{SUM\'ARIO}

\tableofcontents
\vspace{1em}

\addtocontents{toc}{\addvspace{10pt}}
%---------------------------------------------------Entrada de texto
\bibliography{referencias}
\end{document}
I hope that they are suitable as MWEs.
Attachments
c2mwe.cls
(2.64 KiB) Downloaded 367 times
Last edited by localghost on Mon Sep 16, 2013 4:13 pm, edited 1 time in total.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Footrule in Custom Class File

Post by cgnieder »

I believe the problem is that fancyhdr is loaded before geometry. It can be solved by adding the following to the class or the document:

Code: Select all

\AtBeginDocument{%
  % update \headwidth according to geometry settings
  \setlength{\headwidth}{\textwidth}%
}
By the way: the document complains about a to small head height which should be set to 60pt if you want to avoid it. The class also contains the command \center which does only exist indirectly: it is used when you call the environment {center}. This starts a list internally which is why it shouldn't be used without the corresponding \endcenter. It also adds some vertical space. In the place where it is used a \centering would be a better choice. The

Code: Select all

\vspace
in the definition of the page style fpage is causing two overfull vboxes on every page. I'd remove them and rather fix the vertical position of the text by using \multirow's fixup argument (about 2ex seem to be the right amount).

Regards
site moderator & package author
Gwind
Posts: 3
Joined: Fri Sep 13, 2013 7:48 pm

Re: Footrule in Custom Class File

Post by Gwind »

Thanks a lot! You're brilliant!! :D
Post Reply