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.

I'm trying to write a class based on article.cls and I'm having some trouble with \newcommand. Here go the complete files.

Class file

\NeedsTeXFormat{LaTeX2e}[1995/12/01]
 \ProvidesClass{NITclsD}
      [2013/09/06 v1.4h Standard LaTeX document class]
 \newcommand\@ptsize{}
 \newif\if@restonecol   %sem muito sentido pois é single column
 \newif\if@titlepage    %tb não tem folha para titulo
 \@titlepagefalse
 \if@compatibility\else
 \DeclareOption{a4paper}
   {\setlength\paperheight {297mm}%
    \setlength\paperwidth  {210mm}}
 \DeclareOption{a5paper}
    {\setlength\paperheight {210mm}%
     \setlength\paperwidth  {148mm}}
 \DeclareOption{letterpaper}
     {\setlength\paperheight {11in}%
      \setlength\paperwidth  {8.5in}}
 \DeclareOption{landscape}
    {\setlength\@tempdima   {\paperheight}%
     \setlength\paperheight {\paperwidth}%
     \setlength\paperwidth  {\@tempdima}}
 \fi
 \if@compatibility
  \renewcommand\@ptsize{0}
 \else
 \DeclareOption{10pt}{\renewcommand\@ptsize{0}}
 \fi
 \DeclareOption{11pt}{\renewcommand\@ptsize{1}}
 \DeclareOption{12pt}{\renewcommand\@ptsize{2}}
 \if@compatibility\else
 \DeclareOption{oneside}{\@twosidefalse \@mparswitchfalse}
 \fi
 \DeclareOption{twoside}{\@twosidetrue  \@mparswitchtrue}
 \DeclareOption{draft}{\setlength\overfullrule{5pt}}
 \if@compatibility\else
 \DeclareOption{final}{\setlength\overfullrule{0pt}}
 \fi
 \if@compatibility\else
 \DeclareOption{onecolumn}{\@twocolumnfalse}
 \fi
 \DeclareOption{twocolumn}{\@twocolumntrue}
 \DeclareOption{leqno}{\input{leqno.clo}}
 \DeclareOption{fleqn}{\input{fleqn.clo}}
 \DeclareOption{openbib}{%
   \AtEndOfPackage{%
   \renewcommand\@openbib@code{%
      \advance\leftmargin\bibindent
      \itemindent -\bibindent
       \listparindent \itemindent
       \parsep \z@
         }%
     \renewcommand\newblock{\par}}%
  }
 \ExecuteOptions{a4paper,10pt,oneside,onecolumn,final}  %mudei o tamanho da folha
 \ProcessOptions
  %______________________________________________________Inserindo os packages
  \RequirePackage[english,brazil]{babel}
  \RequirePackage[utf8]{inputenc}           % Codificacao do arquivo
  \RequirePackage{cmap}             % Mapear caracteres especiais no PDF
  \RequirePackage[T1]{fontenc}          % Codificacao da fonte
  \RequirePackage{amsmath,amssymb,amsfonts,textcomp}
  \RequirePackage{setspace} 
  \RequirePackage{lastpage}
  \RequirePackage{parskip}
  %.............................Layout...........................
  \RequirePackage[top=3 cm, bottom=3.3 cm, left=1.5 cm, right=1.5 cm, footskip=0.5 cm]{geometry}

  %........................Figuras................................
  \RequirePackage[]{graphicx}               % Para incluir figuras (pacote extendido)
  \RequirePackage{color}                % Suporte a cores

  \graphicspath{{Figuras/}}         
  \RequirePackage{caption}          
 \RequirePackage{multicol}      
 %...........................Tabelas...............................
 \RequirePackage{array}             % Elementos extras para formata\c c\~ao de tabelas
 \RequirePackage{booktabs}              % Tabelas com qualidade de publica\c c\~ao
 \RequirePackage{longtable}             % Para criar tabelas maiores que uma p\'agina
 \RequirePackage{lscape}                    % adicionar tabelas e figuras como landscape
 \RequirePackage{multirow}
 %============================Cabeçalho e rodapé ===================
 \RequirePackage{fancyhdr}
 \LoadClass[a4paper]{article}
 %+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 \if@twoside
   \def\ps@headings{%
      \let\@oddfoot\@empty\let\@evenfoot\@empty
       \def\@evenhead{\thepage\hfil\slshape\leftmark}%
       \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
       \let\@mkboth\markboth
     \def\sectionmark##1{%
       \markboth {\MakeUppercase{%
         \ifnum \c@secnumdepth >\z@
          \thesection\quad
         \fi
        ##1}}{}}%
    \def\subsectionmark##1{%
      \markright {%
        \ifnum \c@secnumdepth >\@ne
          \thesubsection\quad
        \fi
        ##1}}}
\else
   \def\ps@headings{%
     \let\@oddfoot\@empty
    \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
    \let\@mkboth\markboth
    \def\sectionmark##1{%
      \markright {\MakeUppercase{%
        \ifnum \c@secnumdepth >\m@ne
          \thesection\quad
        \fi
         ##1}}}}
\fi
\def\ps@myheadings{%
    \let\@oddfoot\@empty\let\@evenfoot\@empty
     \def\@evenhead{\thepage\hfil\slshape\leftmark}%
     \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
     \let\@mkboth\@gobbletwo
     \let\sectionmark\@gobble
    \let\subsectionmark\@gobble
    }
%---------------------------------------------------------------
     \if@titlepage
  \newcommand\maketitle{\begin{titlepage}%
  \let \footnote \thanks
   \null\vfil
   \vskip 60\p@
   \begin{center}%
     {\LARGE \@title \par}%
     \vskip 3em%
    {\large
      \lineskip .75em%
      \begin{tabular}[t]{c}%
        \@author
      \end{tabular}\par}%
       \vskip 1.5em%
    {\large \@date \par}%       % Set date in \large size.
   \end{center}\par
   \@thanks
  \vfil\null
   \end{titlepage}%
}
\else
\newcommand\maketitle{\par
   \begingroup
    \renewcommand\thefootnote{\@fnsymbol\c@footnote}%
     \def\@makefnmark{\rlap{\@textsuperscript{\normalfont\@thefnmark}}}%
    \long\def\@makefntext##1{\parindent 1em\noindent
             \hb@xt@1.8em{%
                \hss\@textsuperscript{\normalfont\@thefnmark}}##1}%
    \if@twocolumn
      \ifnum \col@number=\@ne
        \@maketitle
      \else
        \twocolumn[\@maketitle]%
      \fi
    \else
      \newpage
      \global\@topnum\z@   % Prevents figures from going at top of page.
      \@maketitle
    \fi
     \thispagestyle{plain}\@thanks
   \endgroup
  \setcounter{footnote}{0}%
 \setcounter{secnumdepth}{3}
 \if@twocolumn
  \setlength\leftmargini  {2em}
\else
  \setlength\leftmargini  {2.5em}
\fi
\leftmargin  \leftmargini
\setlength\leftmarginii  {2.2em}
\setlength\leftmarginiii {1.87em}
\setlength\leftmarginiv  {1.7em}
 \if@twocolumn
   \setlength\leftmarginv  {.5em}
   \setlength\leftmarginvi {.5em}
\else
   \setlength\leftmarginv  {1em}
   \setlength\leftmarginvi {1em}
\fi
  \setlength  \labelsep  {.5em}
  \setlength  \labelwidth{\leftmargini}
  \addtolength\labelwidth{-\labelsep}
  \@beginparpenalty -\@lowpenalty
  \@endparpenalty   -\@lowpenalty
  \@itempenalty     -\@lowpenalty
  \setlength\arraycolsep{5\p@}
  \setlength\tabcolsep{6\p@}
  \setlength\arrayrulewidth{.4\p@}
  \setlength\doublerulesep{2\p@}
  \setlength\tabbingsep{\labelsep}
  \skip\@mpfootins = \skip\footins
 \setlength\fboxsep{3\p@}
 \setlength\fboxrule{.4\p@}
\renewcommand \theequation {\@arabic\c@equation}
\renewcommand \thefigure {\@arabic\c@figure}
\def\fps@figure{tbp}
\def\ftype@figure{1}
\def\ext@figure{lof}
\def\fnum@figure{\figurename\nobreakspace\thefigure}
\def\fps@table{tbp}
\def\ftype@table{2}
\def\ext@table{lot}
\long\def\@makecaption#1#2{%
    \vskip\abovecaptionskip
   \sbox\@tempboxa{#1: #2}%
   \ifdim \wd\@tempboxa >\hsize
     #1: #2\par
   \else
      \global \@minipagefalse
     \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
  \fi
   \vskip\belowcaptionskip}
   \DeclareOldFontCommand{\rm}{\normalfont\rmfamily}{\mathrm}
   \DeclareOldFontCommand{\sf}{\normalfont\sffamily}{\mathsf}
   \DeclareOldFontCommand{\tt}{\normalfont\ttfamily}{\mathtt}
   \DeclareOldFontCommand{\bf}{\normalfont\bfseries}{\mathbf}
   \DeclareOldFontCommand{\it}{\normalfont\itshape}{\mathit}
   \DeclareOldFontCommand{\sl}{\normalfont\slshape}{\@nomath\sl}
   \DeclareOldFontCommand{\sc}{\normalfont\scshape}{\@nomath\sc}
   \DeclareRobustCommand*\cal{\@fontswitch\relax\mathcal}
   \DeclareRobustCommand*\mit{\@fontswitch\relax\mathnormal}
   \setcounter{tocdepth}{3}
   \let\l@table\l@figure
   \newdimen\bibindent
   \setlength\bibindent{1.5em}
   \let\@openbib@code\@empty
   \renewcommand\footnoterule{%
   \kern-3\p@
   \hrule\@width.4\columnwidth
   \kern2.6\p@}
  %++++++++++++++++++++++++++++++++++++++++Definindo meus comandos
  % Definindo tamanho de fonte de se\c c\~oes e subse\c c\ões
  %v. documento www.latex-project.org/guides/fntguide.pdf

 \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
 %----------------------------------------------Comandos necessarios para o documento
 \newcommand*{\@divisao}{}
 \newcommand*{\divisao}[1]{\renewcommand*{\@divisao}{#1}}
 \newcommand*{\@nonorma}{}
 \newcommand*{\nonorma}[1]{\renewcommand*{\@nonorma}{#1}}
 \newcommand*{\@dataaprov}{}
 \newcommand*{\dataaprov}[1]{\renewcommand*{\@dataaprov}{#1}}
 \newcommand*{\@nrevisao}{}
 \newcommand*{\nrevisao}[1]{\renewcommand*{\@nrevisao}{#1}}
 \newcommand*{\@titulonit}{}
 \newcommand*{\titulonit}[1]{\renewcommand*{\@titulonit}{#1}}
 %++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 \def\today{\ifcase\month\or
  January\or February\or March\or April\or May\or June\or
  July\or August\or September\or October\or November\or December\fi
  \space\number\day, \number\year}
 \setlength\columnsep{10\p@}
 \setlength\columnseprule{0\p@}
 \pagestyle{plain}
 \pagenumbering{arabic}
 \if@twoside
 \else
   \raggedbottom
 \fi
 \if@twocolumn
   \twocolumn
   \sloppy
   \flushbottom
 \else
   \onecolumn
 \fi
 \endinput
 %
 % End of file `NITclsD.cls'.

The tex file (I would like to put all these "usepackages" in the .cls file),

\documentclass{NITclsD}
\usepackage{enumitem}               % Cria listas numeradas
\usepackage[compact]{titlesec}          % Formato dos titulos
\usepackage{subfig}             % Criar figura dividida   em subfiguras
\usepackage{natbib}             % Bibliografia
%---------------------------------------------------
\begin{document}
\divisao{DIVISAO}       
\nonorma{001}       %tres digitos
\dataaprov{08/2013} % formato MM/AAAA
\nrevisao{00}       %dois digitos
\titulonit{T\'ITULO}
 %:::::::::::::::::::::::
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}  
\renewcommand{\footrulewidth}{0.4pt}    
%%redefinindo o espa\c camento entre linhas do sum\'ario: sem espa\c co
\newcommand*{\noaddvspace}{\renewcommand*{\addvspace}[1]{}} 
\addtocontents{toc}{\protect\noaddvspace}
%
\renewcommand*\contentsname{SUM\'ARIO}
%
\small\tableofcontents
 \vspace{1em}
%-----------------testezinho
 \addtocontents{toc}{\addvspace{10pt}}
%
 \section{Objetivo}
 \label{1}
 %
 %Here comes the text.
 \bibliography{referencias}
 \end{document}

I still have some errors related to the original article.cls, but I'd like to eliminate the "undefined control sequence" related to the \newcommand. How can I fix it?

share|improve this question
1  
Please, report the whole error message that you find in the log file –  egreg Sep 9 '13 at 16:53
    
\dataaprov{08/2013} % formato MM/AAAA –  awel.llwyd Sep 9 '13 at 17:00
    
!Undefined control sequence. l.22\dataaprov{08/2013} The control sequence at the end of the top line of your error message was never \def'ed. If you have mispelled it (e.g.,'\hobx'), type '|'and the correct spelling (e.g., '\hbox'). Otherwise just continue and I'll forget about whatever was undefined. –  awel.llwyd Sep 9 '13 at 17:06
    
Please, add the code to your question, where it can be properly formatted as the original. –  egreg Sep 9 '13 at 17:09
1  
Sorry, but the class is badly written. –  egreg Sep 9 '13 at 19:35

1 Answer 1

It seems to me that you're first defining a lot of things that are normally defined in article.cls, like for instance \@ptsize, and later on you \LoadClass{article}. What I'm getting is a LaTeX Error: Command \@ptsize already defined, which I find reasonable.

I agree with @egreg that your class is badly written. You may want to consult e.g. acmconf.cls to see how you can customize article.cls in your class.

share|improve this answer
    
I've tried to take \@ptsize out of the cls file. But log file showed an error message in which \@ptsize was missing. Maybe I wasn't clear enough, but I was trying to modify article.cls and besides defining \newcommand for some data, I just took repeated things off and, hence, it got baddly writen. Maybe the .cls you suggested can help. –  awel.llwyd Sep 10 '13 at 11:59
    
@awel.llwyd Taking a copy of article and modifying it is IMHO a bad idea (as long as the differences are rather small resp. you are mainly extending article). Better load article within your class and re-define macros etc. to implement your changes. See clsguide for details. –  Axel Sommerfeldt Sep 11 '13 at 7:35

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.