Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

What about \nobreak does LaTeX not understand?

928 views
Skip to first unread message

googlekathryn

unread,
Sep 25, 2008, 5:49:27 PM9/25/08
to t...@timquinn.name
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.


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}%
}


Dan

unread,
Sep 26, 2008, 12:06:03 AM9/26/08
to
On Sep 25, 4:49 pm, googlekathryn <khargrea...@gmail.com> wrote:
> 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.

[...]


>
>                                 ~\\[-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

Ulrike Fischer

unread,
Sep 26, 2008, 2:49:42 AM9/26/08
to
Am Thu, 25 Sep 2008 14:49:27 -0700 (PDT) schrieb googlekathryn:

> 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

0 new messages