2

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}  

1 Answer 1

2

I would define two chapter styles

\documentclass[11pt]{scrreprt}

\usepackage{lipsum}
\usepackage{titlesec}

\newcommand{\mainchapterstyle}{%
  \titleformat{\chapter}[display]
   {\vspace{\stretch{7}}\normalfont\onehalfspacing\centering\large}
   {\chaptertitlename~\thechapter}
   {1em}
   {\thispagestyle{empty}\vspace{0.5em}}
   [\vspace{\stretch{10}}\cleardoublepage
     \thispagestyle{empty}\singlespacing]}

\newcommand{\appchapterstyle}{%
  \titleformat{\chapter}[hang]
   {}
   {\thechapter}
   {1em}
   {\raggedright}
   [\normalsize\vspace*{.8\baselineskip}\titlerule]}

\begin{document}

\mainchapterstyle
\chapter{Bar}
\lipsum[1-3]

\appendix
\appchapterstyle
\chapter{Foo}    
\lipsum[1-3]

\end{document}
1
  • 1
    @Thomas: it's common to mark the answer as accepted, or, if you want to wait for possible other answers, to at least mark it as useful.
    – egreg
    Apr 24, 2011 at 21:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .