# How to configure fancyhdr depending on the document class [duplicate]

Possible Duplicate:
How to configure theorems depending on the document class?

I would like to have if the book class is loaded but if the article class is loaded. Can I do this with some sort of conditional?

I tried, but failed.

\makeatletter%
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\renewcommand{\chaptermark}[1]{\markboth{\thechapter.\ #1}{}}
\fancyfoot{}
\fancyfoot[LE,RO]{\bfseries\thepage}
\fancyfoot[LO,RE]{Régis}
\renewcommand{\footrulewidth}{0.5pt}
\fancypagestyle{plain}{%
}
\typeout{Using book class.}%
}{%
%   \renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
%   \renewcommand{\chaptermark}[1]{\markboth{\thechapter.\ #1}{}}
\fancyfoot{}
\fancyfoot[R]{\bfseries\thepage}
\fancyfoot[L]{Régis}
\renewcommand{\footrulewidth}{0.5pt}
\fancypagestyle{plain}{%
}
\typeout{Using article class.}%
}{%
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\renewcommand{\chaptermark}[1]{\markboth{\thechapter.\ #1}{}}
\fancyfoot{}
\fancyfoot[R]{\bfseries\thepage}
\fancyfoot[L]{Régis}
\renewcommand{\footrulewidth}{0.5pt}
\fancypagestyle{plain}{%
}
\typeout{Using report class.}%
}{%
\typeout{Error: Unsupported class: 'article' or 'report' or 'book' are suported.}\QUITHERE
}%
}%
\makeatother%


## marked as duplicate by Caramdir, Alan Munn, Werner, frabjous, SeamusAug 12 '11 at 10:06

This should get you started. Just add the appropriate settings to BookHeader, ArticleHead, and ReportHead. Within these three you can use #1 to refer to what was passed to \SetHeaders.

The following is intended to exit if a class other than book or article or report is used. You can remove the \QUITHERE macro if that is not desired.

\documentclass{article}

\typeout{Using book class.}%
}%

\typeout{Using article class.}%
}%

\typeout{Using report class.}%
}%

\makeatletter%
\typeout{Error: Unsupported class: 'article' or 'report' or 'book' are suported.}\QUITHERE
}}}%
}%
\makeatother%


• This is definitely easier to read code. (The original code also worked; see my comment above.) Also, @Regis Peter has the pseudo-code macro \QUITHERE; this document will fail inelegantly if an unsupported document class is used. – Alan Munn Aug 12 '11 at 5:20
• How to use \renewcommand{\chaptermark}[1]{\markboth{\thechapter.\ #1}{}} for appear 1.foo (name of chapter) without CHAPTER 1.foo. Is failed in Report. – Regis da Silva Aug 12 '11 at 5:24
• It's also possible to use \PackageError{<package name>}{<error text>}{<help text>} inside a document. – Alan Munn Aug 12 '11 at 6:05