I aim at using to types of chapter headings in my document: for preambule and appendix, simple underlined upper case, while for the main chapters, I want to have a full page with "chapter n / Title" on two different lines…
I (almost) managed to do it by defining a new environment "chapterpage" and by passing arguments to \titleformat (from titlesec package) as macros (that are not defined in the same way in global and chapterpage environments.
However, I do not manage to pass the first optional argument to \titleformat following this way :( I need this as I want to use a hang shape in the former layout and a display one in the latter. I suspect it may be solved using the appropriate \protect commands, but I did not manage to fix it!
Here is a minimal example. If it worked, "Chapter 2" and "Bar" should be printed on different lines. Thank you for your help.
\documentclass[11pt]{scrreprt}
\usepackage{lipsum}
\usepackage{titlesec}
\usepackage{setspace}
\newcommand{\mychapterShape}{hang} % hang is for aligning the number with the title
\newcommand{\mychapterFormat}{\relax}
\newcommand{\mychapterBefore}{\raggedright}
\newcommand{\mychapterAfter}{\normalsize\vspace*{.8\baselineskip}\titlerule}
\newcommand{\mychapterLabel}{\thechapter} %{\relax}
\newenvironment{chapterpage}
{
\renewcommand{\mychapterShape}{display}
\renewcommand{\mychapterFormat}{
\vspace{\stretch{7}}\normalfont\onehalfspacing\centering\large
}
\renewcommand{\mychapterBefore}{
\thispagestyle{empty}%
%\begin{addmargin}[1cm]{0cm}%
\vspace{0.5em}%
}
\renewcommand{\mychapterAfter}{
\vspace{\stretch{10}}\cleardoublepage\thispagestyle{empty}\singlespacing
}
\renewcommand{\mychapterLabel}{\chaptertitlename~\thechapter}
}
{} % end chapterpage envt
\titleformat{\chapter}[\mychapterShape]%
{\mychapterFormat}{\mychapterLabel}{1em}%
{\mychapterBefore}[\mychapterAfter]%
\begin{document}
\chapter{Foo}
\lipsum[1-3]
\begin{chapterpage}
\chapter{Bar}
\end{chapterpage}
\lipsum[1-3]
\end{document}
