Does anyone know how to put a frame around \chapter and \section-headings? I'm using Koma-Script (scrbook) but there it's rather difficult to find a solution ...
Now I found the package 'titlesec'. I think it must be possible to solve my problem with it but unfortunately I don't get it.
Here's a little code-example with some (hanging!) \chapter and \section's where I want a frame around ...
\documentclass[oneside,openright,BCOR=5mm,paper=a4,fontsize=11pt]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[automark]{scrpage2}
\usepackage{xcolor}
\usepackage{geometry}
\geometry{a4paper, top=35mm, left=30mm, right=60mm, bottom=25mm, headsep=15mm, footskip=12mm}
\usepackage[demo]{graphicx}
\usepackage{textpos}
\usepackage{blindtext}
\usepackage{lipsum}
\usepackage{titlesec}
\usepackage{mparhack}
\setlength{\marginparwidth}{3.2cm}
\setlength{\marginparsep}{0.7cm}
\setheadwidth[0pt]{textwithmarginpar}
\setfootwidth[0pt]{head}
\titleformat{\chapter}[hang]{}{\parbox{1.5cm}{\thechapter}}{0pt}{}{}
\titleformat{\section}[hang]{}{\parbox{1.5cm}{\thesection}}{0pt}{}{}
\titleformat{\subsection}[hang]{}{\parbox{1.5cm}{\thesubsection}}{0pt}{}{}
\titleformat{\subsubsection}[hang]{}{\parbox{1.5cm}{\thesubsubsection}}{0pt}{}{}
\begin{document}
\chapter{Lorem ipsum}
One
\section{dolor}
Two
\subsection{amet}
Three
\end{document}
I also added an image where you can see the result that I want to get ... but unfortunately don't know either how to manage.
On the other hand I've already a solution by redefining \makechapterhead and defining a new \Section (capital 's') for framed section headings. Unfortunately I neither wasn't able to add the 'spacing' between chapter/section-number and chapter/section-heading in this redefinitions nor to redefine section in the way that I don't have to use this new command 'Section' :(
\renewcommand\section{\@startsection{section}{1}{\z@}%
{-0.0ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\ifnum \scr@compatibility>\@nameuse{scr@[email protected]}\setlength{\parfillskip}{\z@
plus 1fil}\fi
\raggedsection\normalfont\sectfont\size@section}%
}
\renewcommand\@@makechapterhead[1]{
\begin{mdframed}[linewidth=0.0pt, innerleftmargin=0, innerrightmargin=0, innertopmargin=2pt, innerbottommargin=0, backgroundcolor=lightgray]
{%
\setlength{\parindent}{\z@}\setlength{\parfillskip}{\fill}%
\normalfont\sectfont\nobreak\size@chapter{}%
\if@chapterprefix
\let\@tempa\raggedsection
\else
\let\@tempa\@hangfrom
\fi
\@tempa{\ifnum \c@secnumdepth >\m@ne%
\if@mainmatter
\if@chapterprefix
\expandafter\size@chapterprefix
\else
\expandafter\size@chapter
\fi
{\chapterformat}%
\if@chapterprefix
\size@chapterprefix{}\endgraf\nobreak\vskip.5\baselineskip
\fi
\fi
\fi
}%
{\raggedsection \interlinepenalty \@M \size@chapter{#1}\par}}%
\nobreak
\end{mdframed}
\vspace*{0.5\baselineskip}
}
\newcommand\Section[2][]{\begin{mdframed}[linewidth=0.5pt, innerleftmargin=0, innerrightmargin=0, innertopmargin=2pt, innerbottommargin=2pt, linecolor=gray, skipabove=24pt]%
\ifx\relax#1\relax\section{#2}\else\section[#1]{#2}\fi
\end{mdframed}}
It would be great if someone could help me! Thank you in advance and greetings from Austria.
--
There's the picture I mentionned below:
-- Code Example for @Herbert --
\documentclass[oneside,openright,BCOR=5mm,paper=a4,fontsize=11pt]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[automark]{scrpage2}
\usepackage{xcolor}
\usepackage{geometry}
\geometry{a4paper, top=35mm, left=30mm, right=60mm, bottom=25mm, headsep=15mm, footskip=12mm}
\usepackage[demo]{graphicx}
\usepackage{textpos}
\usepackage{blindtext}
\usepackage{lipsum}
\usepackage{mparhack}
\setlength{\marginparwidth}{3.2cm}
\setlength{\marginparsep}{0.7cm}
\setheadwidth[0pt]{textwithmarginpar}
\setfootwidth[0pt]{head}
\begin{document}
\pagestyle{scrheadings}
\clearscrheadfoot
\pagenumbering{Roman}
\cfoot[\hspace{10.5cm}\today]{\hspace{10.5cm}\today}
\ofoot[\pagemark]{\pagemark}
\chapter{Lorem ipsum}
\lipsum[1-3]
\newpage
\pagenumbering{arabic}
\setcounter{page}{1}
\clearscrheadfoot
\ifoot[%
{%
\par% sonst gibt es eine Warnung
\begin{textblock*}{0mm}(0.78\paperwidth,-0.25\paperheight)%
\includegraphics[scale=0.30, angle=90]{demo}
\end{textblock*}
}%
]{%
{%
\par% sonst gibt es eine Warnung
\begin{textblock*}{0mm}(0.78\paperwidth,-0.25\paperheight)%
\includegraphics[scale=0.30, angle=90]{demo}
\end{textblock*}
}%
}%
\cfoot[\hspace{10.5cm}\today]{\hspace{10.5cm}\today}
\ofoot[\pagemark]{\pagemark}
\chapter{Super}
\blindtext
\par
\blindtext
\end{document}
--- @Herbert
In the code example before there has to be included \usepackage{titletoc} and the following code block before \begin{document}:
\titlecontents{chapter}[2.5cm]{\addvspace{0.5cm}\bfseries}{\contentslabel{3.5cm}}{\hspace*{-1.5cm}}{\hfill\contentspage}[\addvspace{0.25cm}]
\titlecontents{section}[2.5cm]{\small}{\contentslabel{3.5cm}\small}{}{\titlerule*[0.12cm]{.}\contentspage}
\titlecontents{subsection}[2.5cm]{\small}{\contentslabel{3.5cm}\small}{}{\titlerule*[0.12cm]{.}\contentspage}
\titlecontents{subsubsection}[2.5cm]{\small}{\contentslabel{3.5cm}\small}{}{\titlerule*[0.12cm]{.}\contentspage}
In the Latex-Body the table of contents is going to be printed by using \tableofcontents. So far so good, now - with all redefinitions of \chapter \section etc., the table of contens looks like
... but, it should look like (this result I get without the redefinitions)