Unifying article and report

I'm formating my thesis. When writing drafts I used documentclass article and now I'm migrating to a template which uses documentclass report. I don't like to manualy change \section to \chapter and \subsection to \section and also a couter for theorems from section to counter. Is there an abstraction layer in LaTeX telling me what the toplevel sectioning environment is?

Also in article, \refname is used for bibliography name but \bibname is used in report. Bibliography is added to the table of contents in report but not in article.

Is there a way to unify the text of individual chapters and bibliography so it works consistently with both article and report?

• This could help: Macro for promoting sections to chapters – mvkorpel Jul 7 '14 at 12:48
• what features of report are you looking for, \chapter is by far the major difference, so if you don't want to change to \chapter it is probably simpler just to use article and then add any extra features that you need. – David Carlisle Jul 7 '14 at 12:58
• @mvkorpel: I added a comment to the refered question. There is an issue with \thebibliography. – user87690 Jul 7 '14 at 13:02
• @DavidCarlisle I'm not sure what features I'm looking for. I don't know which internal parameters are different and which matter for me. The point is I want universal core text files which work with both article and report. Of course I can define helper macros. I'm asking if this can be done automatically because e.g. \thebibliography uses \chapter in report and \section in article, so how does it know? – user87690 Jul 7 '14 at 13:05
• have a look at package coseoul. – Johannes_B Feb 22 '15 at 13:02

From the comments, consider using the coseoul package. This provides commands for headings of the form \levelstay, \leveldown and \levelup and a package option initlevel for the initial level, e.g. chapter or section.

here is a solution (you need to work as it is article i.e. don't use \chapter command)

Edit: Sorry I did not see Gonzalo Medina's answer to this Macro for promoting sections to chapters

\documentclass{article}
%\documentclass{report}
\ifx\chapter\undefined
\else
\let\subsubsection\subsection
\let\subsection\section
\let\section\chapter
\setcounter{secnumdepth}{2}
\setcounter{tocdepth}{2}
\fi

\begin{document}
\tableofcontents
\section{Foo section}
\subsection{Foo subsection}
\subsection{Bar subsection}
\subsubsection{Foo subsubsection}
\section{Bar section}
\subsection{Bar subsection}
\subsection{Baz subsection}
\subsubsection{Bar subsubsection}
\end{document}

• Thank you for the answer. Since the question was asked I have improved my approach to this problem. Currently, I use a relative section environment that can be nested and all levels use the same command. It's up to my macros to invoke \section, \subsection etc. where appropriate. – user87690 Sep 3 '15 at 11:07