# 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

Didn't we just answer an identical question of yours like this: How to configure theorems depending on the documentclass? This is (another) duplicate of Which document class is being used? –  Alan Munn Aug 11 '11 at 20:07
Alan is correct. Just inserting the appropriate sections of your code into the solution at How to configure theorems depending on documentclass should work. –  Peter Grill Aug 11 '11 at 20:13
I tried, but failed. –  Regis da Silva Aug 12 '11 at 3:55
can not you have two environments \makeatletter% on the same file? –  Regis da Silva Aug 12 '11 at 4:13
The #1 is intended to refer to the first parameter to a macro call. Here you are not defining a macro so it doesn't have meaning. –  Peter Grill Aug 12 '11 at 4:13

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