Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm relatively inexperienced with Latex. I'm using the Memoir class and I've been trying to develop a custom chapter style based on Danie Els' BlueBox style (the source for this is given on page 46 of Memoir Chapter Styles).

I'd like to redefine the chapter command to take two arguments, such as below:

\chapter{ExampleChapter}{A short description of the contents of this chapter}

I'd then like to have both arguments passed to a redefined version of \printchaptertitle so that I can print the description beneath the title:

\renewcommand{\printchaptertitle}[2]{%
\usebox{\ChpNumBox}\hfill
\parbox[t]{\hsize-\wd\ChpNumBox-1em}{%
\vspace{\midchapskip}%
\thickhrulefill\par
\chaptitlefont ##1\par}}%2
% ##2 is used somewhere here
}

EDIT

I hacked something ugly together that's pretty close to what I want:

I redefine the afterchapskip length within the chapter style to be negative:

\setlength{\afterchapskip}{-45pt}

I then define the following macro:

\newcommand{\addChapter}[2] {
\chapter{#1}
\begin{flushright}
\parbox[t]{\hsize-\wd\ChpNumBox-5em}{\flushright\small{\textcolor{dark-gray}{#2}}}
\end{flushright}
\vspace{30pt}
}

Then within the document itself I use:

\addChapter{Example Chapter}{A short description of the contents of this chapter. I can ramble on a bit just to point out that this is flushed right.}

That produces the following:

EDIT 2

Using daleif's recommended approach below, I've got something that works quite nicely.

I define the following:

\def\chapterDesc{}
%...
\newcommand{\setChapterDescription}[1]{%
\def\chapterDesc{#1}%
}
%...
\newcommand{\addChapter}[2]{
\setChapterDescription{#2}
\chapter{#1}
\setChapterDescription{}
}
%...
\renewcommand{\printchaptertitle}[1]{%
\usebox{\ChpNumBox}\hfill
\parbox[t]{\hsize-\wd\ChpNumBox-1em}{%
\vspace{\midchapskip}%
\thickhrulefill\par
\chaptitlefont ##1\par
\vspace{20pt}
\normalfont\small\textcolor{dark-gray}{\chapterDesc}}
}%2
}

I can then do something like the following:

\addChapter{Example Chapter}{A short description of the contents of this chapter. I can ramble on a bit just to point out that this is flushed right.}

Or just:

\chapter{Descriptionless Chapter}

share|improve this question
    
You do not need \setChapterDescription{} in \addChapter, just add \gdef\chapterDesc{} at the end of \printchaptertitle. And next time, please post full minimal examples, including preamble and such. That makes it a lot easier for people to use or test your suggestion –  daleif Jul 28 at 10:50

1 Answer 1

up vote 4 down vote accepted

That would take a lot of work. It would be easier to use a two macro approach.

I usually do this independently of \chapter using \chapterprecis.

If you wanted it directly into the chapter style it might be better to use an approach like

\setchapterdesc{....}
\chapter{....}

and then let the chapter style use the macro that the imaginary macro \setchapterdesc stores its value in (remember to globally clear it after use)

share|improve this answer
    
Thanks! Using global variables had crossed my mind, though I wasn't sure about how they're used within Latex. I'm guessing defining setChapterDesc to something like "\def\chapterDesc{#1}" should work, and then I just use \chapterDesc within \printchaptertitle. I'll try this out! –  Tagc Jul 28 at 10:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.