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 am trying to build a class with a title block (using titling) such that the end user enters data into two fields. One variable is sopchaptertitle, and the other is sopchapternumber. I want to then concatenate them, and place the resulting title some distance from the top of the page and centered on the page. This will be followed by some distance of white space and the first section.

It should look something like this: enter image description here

This is my code:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{sop}

% Passes and class options to the underlying article class
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions
\LoadClass{article}

% Redefine the page margins
\RequirePackage[left=1in,right=1in,top=.75in,bottom=.75in]{geometry}

% Modifications to the section titles
\renewcommand*\thesection{\arabic{section}.0}
\renewcommand*\thesubsection{\arabic{section}.\arabic{subsection}}
\renewcommand*\thesubsubsection{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}}

% Title block
\RequirePackage{titling}
\newcommand{\sopchaptertitle}[1]{\newcommand{\thesopchaptertitle}{#1}}
\newcommand{\sopchapternumber}[1]{\newcommand{\thesopchapternumber}{#1}}
\let\oldtitle\title
\renewcommand{\title}[1]{\oldtitle{#1}\newcommand{\mythetitle}{#1}}
\let\oldpretitle\pretitle
\renewcommand{\pretitle}[1]{\oldpretitle{#1}\newcommand{\mythepretitle}{#1}}
\let\oldposttitle\posttitle
\renewcommand{\posttitle}[1]{\oldposttitle{#1}\newcommand{\mytheposttitle}{#1}}
\renewcommand{\maketitle}{%
\mythepretitle{\setlength{\droptitle}{12.0cm}\begin{center}\LARGE}
\mythetitle{\thesopchaptertitle\ \thesopchapternumber}
\mytheposttitle{\par\end{center}\vskip 0.5em}
}
%.... a page N of M section (which works)
% For easier customization of itemized, enumerated, and other lists
\RequirePackage{enumitem}
% For hyperlinked cross-references
\RequirePackage{hyperref}
% Ensure first page is correct style
\thispagestyle{plain}
% That's all, folks!
\endinput

It is being fed this:

\documentclass[10pt]{sop}
%
% SOP Standard Form Data
\sopchaptertitle{This is my procedure title}
\sopchapternumber{this is my procedure number D.4}
%...more of the above
%Here begins the actual document
\begin{document}

\maketitle

\section{Main Title}

\section{Approval}
Approval1....\makebox[1.5in]{\hrulefill}\\\vspace{1.5in}
Approval2....\makebox[1.5in]{\hrulefill}

\newpage

\section{Purpose and Discussion}
%...more of the above...
\end{document}

And I am getting these errors:

(/usr/share/texmf/tex/latex/oberdiek/rerunfilecheck.sty)))
! Missing = inserted for \ifnum.
<to be read again> 
                   M
l.4 \sopchaptertitle
                    {this is my procedure title}
? 
! Missing number, treated as zero.
<to be read again> 
                   M
l.4 \sopchaptertitle
                    {this is my procedure title}
? 

And

(/usr/share/texmf/tex/generic/oberdiek/gettitlestring.sty)) (./sop-test.out)
(./sop-test.out)
! Undefined control sequence.
\HyOrg@maketitle ->\mythepretitle 
                                  {\setlength {\droptitle }{12.0cm}\begin {c...
l.15 

? 
! Extra }, or forgotten \endgroup.
\HyOrg@maketitle ...12.0cm}\begin {center}\LARGE }
                                                   \mythetitle     {\thesopchapt...
    l.15 

? 
! Undefined control sequence.
\HyOrg@maketitle ... {center}\LARGE } \mythetitle 
                                                  {\thesopchaptertitle \ \th...
l.15 

? 
! Undefined control sequence.
\HyOrg@maketitle ...apternumber } \mytheposttitle 
                                                  {\par \end {center}\vskip ...
l.15 

? 
! Missing } inserted.
<inserted text> 
                }
l.15 

? 

The braces seem balanced, and everything but the droptitle seems to work.

Could someone please explain why droptitle is not functioning?

share|improve this question
1  
Welcome to TeX.sx! –  Peter Jansson Mar 7 '13 at 17:22
    
It's hard to tell without a complete example; there's hyperref involved but your code doesn't load it. –  egreg Mar 7 '13 at 17:31
    
@egreg - I am not using any links in this. How does hyperref play a role? It is being loaded, however. –  Matt Mar 7 '13 at 20:14
    
I don't know; but the problem is certainly related to hyperref, as it's the package that uses the prefix HyOrg for commands it redefines. –  egreg Mar 7 '13 at 20:18
    
@egreg Probably comes from the titling package. –  Yiannis Lazarides Mar 7 '13 at 20:20
show 8 more comments

1 Answer

The problem is that \mythepretitle is called without ever being given a definition.

According to the code in sop.cls, you have

\let\oldpretitle\pretitle
\renewcommand{\pretitle}[1]{\oldpretitle{#1}\newcommand{\mythepretitle}{#1}}

but you never do

\pretitle{something}

so \mythepretitle is never defined, although you want to use it in \maketitle.

It's not clear why you want an exact duplicate of \pretitle. In titling.sty we find

\newcommand{\pretitle}[1]{\def\@bspretitle{#1}}

so when used in \maketitle it will use the argument at the right spot, see the definition of \maketitle. But you're redefining \maketitle yourself, so the loading of titling becomes completely useless and using \pretitle instead of \mythepretitle will do nothing.


Using the features provided by titling you can achieve your result more easily:

sop.cls

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{sop}

% Passes and class options to the underlying article class
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions
\LoadClass{article}

% Redefine the page margins
\RequirePackage[left=1in,right=1in,top=.75in,bottom=.75in]{geometry}

% Modifications to the section titles
\renewcommand*\thesection{\arabic{section}.0}
\renewcommand*\thesubsection{\arabic{section}.\arabic{subsection}}
\renewcommand*\thesubsubsection{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}}

% Title block
\RequirePackage{titling}
\newcommand{\sopchaptertitle}[1]{\def\@sopchaptertitle{#1}}
\newcommand{\sopchapternumber}[1]{\def\@sopchapternumber{#1}}

%%% Drop before title
\setlength\droptitle{12cm}

%%% Define the internal variable \@title to be the supplied data
\renewcommand\maketitlehooka{%
  \def\@title{\@sopchaptertitle\ \@sopchapternumber}}

%%% No author field, so \maketitlehookb gobbles what comes after it
\renewcommand\maketitlehookb[1]{}

%%% No date field, so \maketitlehookc gobbles what comes after it
\renewcommand\maketitlehookc[1]{}

%%% Formatting the title
\pretitle{\centering\sffamily\LARGE}

%%% Space after the title
\posttitle{\par\vspace{3cm}}

%%% The rest of the class    

%.... a page N of M section (which works)
% For easier customization of itemized, enumerated, and other lists
\RequirePackage{enumitem}
% For hyperlinked cross-references
\RequirePackage{hyperref}
% Ensure first page is correct style
\thispagestyle{plain}
% That's all, folks!
\endinput

If we use this with your minimal example, we get the following result

enter image description here

Probably the drop should be adjusted, taking into account the top margin, the head height and the head separation. If you want exactly 12cm from the top paper margin, possibly

 \setlength{\droptitle}{\dimexpr 12cm-0.75in-\headheight-\headsep\relax}

is what you need.

share|improve this answer
    
The structure of everything is starting to make more sense. I'm still not there, but this helped. –  Matt Mar 7 '13 at 22:34
    
@Matt I updated the answer based on the additional information you gave –  egreg Mar 7 '13 at 22:59
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.