I use the following (minimized) code to build section heads followed
by headlines. In this case, the section head is a simple rule. The
\nobreaks don't hold things together, so I use \needspace, which does
hold things together but messes up plenty of other things.
I also get orphan section heads if I don't use \needspace;
\afterheading doesn't help.
Regards,
Kathy
\newcommand{\rulesectionhead}[1]%
{%
\penalty-9000% Smaller than \@secpenalty (-5000)
\needspace{6\baselineskip}% Increase this, not headline's
needspace, to not orphan self.
\parbox[t]{\textwidth}
{%
~\\[-24.50bp]%
\textcolor{blue}{\rule{\textwidth}{.35bp}}\\%
\nobreak\vskip-4.85bp\nobreak%
\gdef\prevthingset{\rrulesectionhead}%
}%
}%
\newcommand{\caheadline}[1]{%
\addcontentsline{toc}{mcrsectiondescr}{#1}%
\nobreak%
\returnamounta%
% rulesectionhead headline boldsubhead subhead
{\vspace{-22.655bp}}{\vspace*{0.00bp}}{\vspace*{0.00bp}}
{\vspace*{0.00bp}}%
% runin body figure footnotes
{\vspace*{0.00bp}}{\vspace*{0.00bp}}{\vspace*{0.00bp}}
{\vspace*{0.00bp}}%
%
\nobreak%
\barecaheadline{#1}%
}% End \caheadline
\newcommand{\barecaheadline}[1]%
{%
\needspace{2\baselineskip}% If larger than 2, separates from the
sectionheads.
\raggedright%
\textcolor{blue}%
{%
\whitneyonefivfont{#1}\\\nobreak%
}%
\afterheading% Equivalent to \@afterheading.
\gdef\prevthingset{\rheadline}%
}
For reference:
\newif\ifnobreak
%
\def\afterheading{%
\global\nobreaktrue%
\everypar{%
\ifnobreak%
\global\nobreakfalse%
{\setbox0\lastbox}%
\clubpenalty10000%
\else
\clubpenalty1000%
\everypar{}%
\fi}%
}
[...]
>
> ~\\[-24.50bp]%
> \textcolor{blue}{\rule{\textwidth}{.35bp}}\\%
> \nobreak\vskip-4.85bp\nobreak%
The first \nobreak is part of the previous paragraph, which
consists of a "~", a rule and an empty line (after \\). A \nobreak
in a paragraph either prevents a line break or (if it occurs at the
beginning of a line, as here) does nothing.
The \vskip ends the paragraph and inserts a vertical space.
TeX usually permits a page break *before* a vskip and so
the \nobreak has no effect. The proper sequence is
\par % to end the paragraph
\nobreak
\vskip...
>
> \newcommand{\caheadline}[1]{%
[...]
> {\vspace*{0.00bp}}{\vspace*{0.00bp}}{\vspace*{0.00bp}}{\vspace*{0.00bp}}%
> %
> \nobreak%
Here again, \nobreak *after* vertical space has no effect.
There are a few packages and some document classes that allow
you to customize section titles. Most of them allow you to specify
a rule below the title.
LaTeX's own \section command holds together the title and the
next two lines of text. These packages/classes adhere to
that rule as well.
The packages are secsty and titlesec. The classes are memoir
and the koma-script classes. I can't say for sure if all allow
underlined titles, but they are where I would go first if I wanted to
get underlined section titles.
Dan
> Hi,
>
> I use the following (minimized) code to build section heads followed
> by headlines. In this case, the section head is a simple rule. The
> \nobreaks don't hold things together, so I use \needspace, which does
> hold things together but messes up plenty of other things.
>
> I also get orphan section heads if I don't use \needspace;
> \afterheading doesn't help.
color commands can insert break point:
http://www.latex-project.org/cgi-bin/ltxbugs2html?pr=graphics%2F3417
You can try {\color{blue}\nobreak\rule ....}
Or -- more radical -- in the preamble:
\makeatletter
\let\Oriset@color\set@color
\renewcommand\set@color{\Oriset@color\nobreak}
\makeatother
--
Ulrike Fischer