2

I have a complex document which requires the use of many levels of document structures. In particular, the first two levels, \part and \chapter are reserved for meta-information while \section plays the role of \chapter in ordinary documents. However, it seems that packages like fncychap can only decorate \chapter. So here comes the question: how can I use the fncychap's chapter style for \section?

(I'm using koma-script's scrreprt class, if relevant.)

MWE:

\documentclass[fontsize=22pt]{scrreprt}

\usepackage[Sonny]{fncychap}
\renewcommand*{\DOCH}{}
\ChTitleVar{\large\sffamily}

\newcommand*{\mypart}[1]{
  \refstepcounter{part}
  \addcontentsline{toc}{part}{\protect\numberline{\thepart}#1}
}
\newcommand*{\mychap}[1]{
  \refstepcounter{chapter}
  \addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}#1}
}

\begin{document}
\tableofcontents

\mypart{big picture level 1}
\mychap{big picture level 2}
% \mypart and \mychap are used for adding meta-information

\section{real chapter here}
% \section is used like \chapter in ordinary documents
% I want the section title etc. to show up using fncychap's style

\end{document}
6
  • Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – user31729
    Aug 10, 2014 at 23:40
  • Hi, I have added a MWE. Aug 11, 2014 at 0:29
  • Package titlesec could be a solution, but its usage in conjunction with KOMA classes is discouraged
    – user31729
    Aug 11, 2014 at 0:36
  • Do your \mypart and \mychapter macros do anything other than place things in the table of contents? (i.e., do they produce any other output in your document?) If not, you should just create new counters and not (ab)use the part and chapter counters.
    – Alan Munn
    Aug 11, 2014 at 3:07
  • @AlanMunn Hi, will custom counters work with tocloft? I need them to appear on a toc which is heavily customized by tocloft. Aug 11, 2014 at 5:14

1 Answer 1

4

Rather than abuse the existing chapter and part counters for your metadata, you can create new items to add to the Table of Contents using the existing facilities of tocloft. Then you can use the fncychap formatting for chapters normally.

As part of its ability to create new contents lists, tocloft provides a command \newlistentry which lets you populate an existing list with TOC entries. It creates the counter for you, and then you use regular tocloft methods for assigning formatting to the entries. Here's an example which should get you going:

\documentclass[fontsize=22pt]{scrreprt}

\usepackage[Sonny]{fncychap}
\renewcommand*{\DOCH}{}
\ChTitleVar{\large\sffamily}

\usepackage{tocloft}
\newlistentry{mypart}{toc}{0}
\newlistentry{mychap}{toc}{0}
\renewcommand{\cftmypartfont}{\itshape}
\renewcommand{\cftmychapfont}{\sffamily}

\newcommand*{\mypart}[1]{
  \refstepcounter{mypart}
  \addcontentsline{toc}{mypart}{\protect\numberline{\themypart}#1}
}
\newcommand*{\mychap}[1]{
  \refstepcounter{mychap}
  \addcontentsline{toc}{mychap}{\protect\numberline{\themychap}#1}
}


\begin{document}
\tableofcontents

\mypart{big picture level 1}
\mychap{big picture level 2}
% \mypart and \mychap are used for adding meta-information

\chapter{real chapter here}
% \section is used like \chapter in ordinary documents
% I want the section title etc. to show up using fncychap's style
\end{document}

Table of Contents image

1
  • Thanks for the answer! I have come up with my solution, too, which is to abuse those commands even further: define \mysec and run \chapter* inside it with the section name. :) Aug 12, 2014 at 12:42

You must log in to answer this question.

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