I want to write my own package as a collection of other packages I often use.
Some declarations in my package only work for book, some for article, and the remaining work for both.
In (La)TeX, how can we make a conditional declaration ?
\ProvidesPackage{MyPackage}
\newcommand\ContentsDir{Contents/}
\newcommand\ChapterDir{\ContentsDir}
%==============================================
%== It will be defined for book document class
%==============================================
\newcommand\IncludeChapter[1]{%
\renewcommand\ChapterDir{\ContentsDir#1/}%
\include{\ContentsDir#1}%
}
\newcommand\IncludeOnlyChapter[1]{%
\includeonly{\ContentsDir#1}%
}
\newcommand\Chapter[1]%
{%
\chapter{#1}%
%\addcontentsline{toc}{chapter}{#1}%
}%
%==============================================
%==============================================
%== Common commands
%==============================================
\newcommand\SectionDir{\ChapterDir}
\newcommand\InputSection[1]{%
\renewcommand\SectionDir{\ChapterDir#1/}
\input{\ChapterDir#1}%
}
%----------------------------------------------
\newcommand\SubSectionDir{\SectionDir}
\newcommand\InputSubSection[1]{%
\renewcommand\SubSectionDir{\SectionDir#1/}
\input{\SectionDir#1}%
}
%----------------------------------------------
\newcommand\InputSubSubSection[1]{%
\input{\SubSectionDir#1}%
}
%----------------------------------------------
\newcommand\Section[1]%
{%
\section{#1}%
%\addcontentsline{toc}{section}{#1}%
}%
%----------------------------------------------
\newcommand\SubSection[1]%
{%
\subsection{#1}%
%\addcontentsline{toc}{chapter}{#1}%
}%
%----------------------------------------------
\newcommand\SubSubSection[1]%
{%
\subsubsection{#1}%
%\addcontentsline{toc}{chapter}{#1}%
}%
%----------------------------------------------