GeneralOrphans and widows

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
ddenton
Posts: 34
Joined: Tue Mar 20, 2007 6:08 pm

Orphans and widows

Post by ddenton »

I am preparing a book that is composed of hundreds of very short stories. I want the title of each story to be centred and in caps (no special font or bold). Some are multi-line titles. And I want the person who recounted the story to be named after the story in flush right. In each chapter there are dozens of stories. There is no need for the story titles to appear in the table of contents.

The way I set it up originally was using the center environment for the titles for each story and the flushright environment for the name of the "author" of the story. This looks perfect, except for the fact that I get lots of orphans and widows.

Does any one have a suggestion on how to set this up? The "author"s name must stay with the story and so must the title.

Thanks in advance.

David

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

ddenton
Posts: 34
Joined: Tue Mar 20, 2007 6:08 pm

Re: Orphans and widows

Post by ddenton »

I solved the first problem by coding all the story titles as subsections and then redefining the subsection:

\makeatletter
\renewcommand\subsection{\@startsection
{subsection}{1}{0mm} % name, level, indent
{-\baselineskip} % beforeskip
{0.5\baselineskip} % afterskip
{\normalfont\normalsize\centering\MakeUppercase}}
\makeatother

I still have a problem with the names of the authors. How do I keep them together with the stories?

Any help would be appreciated.

Thanks
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Orphans and widows

Post by localghost »

Regarding the title of this thread, try the solution from another thread [1] with exactly the same topic.

[1] Forum thread: Widows and Orphans
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Orphans and widows

Post by gmedina »

The titlesec package can be useful. I include an example showing something similar to what you described:

Code: Select all

\documentclass{article}
\usepackage{titlesec}

\newcommand{\theAuthor}{}

\newcommand{\secformat}[1]{%
 \parbox[b]{\textwidth}{\filcenter{\Large\scshape #1}}%
 \par\vspace*{.5\baselineskip}%
 \filleft\itshape\theAuthor}

\titleformat{\subsection}[block]
 {}{}{0pt}{\secformat}

\begin{document}

\renewcommand\theAuthor{First author}
\subsection{first story}
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text 

\renewcommand\theAuthor{First author and Second author}
\subsection{second story\\ {\small\normalfont (my favorite)}}
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text 

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
ddenton
Posts: 34
Joined: Tue Mar 20, 2007 6:08 pm

Re: Orphans and widows

Post by ddenton »

Thank you to both, especially to gmedina for your example. This is really good.

However, what if I wanted to put the author at the end of the story (with similar formatting to your example)? How might that work so that the author's name stayed with the story and is not left on it's own.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Orphans and widows

Post by gmedina »

In that case, I would suggest something like the code below (using the advise that localghost gave you); if necessary, you will have to manually correct any misplacements of the authors.

Code: Select all

\documentclass{book}
\usepackage{titlesec}

\clubpenalty10000
\widowpenalty10000

\newcommand{\secformat}[1]{%
 \parbox[b]{\textwidth}{\filcenter{\Large\scshape #1}}}%

\titleformat{\subsection}[block]
 {}{}{0pt}{\secformat}

\newsavebox{\storyAuthor}
\newenvironment{theStory}[2]%
 {\sbox{\storyAuthor}{\itshape#2}%
  \subsection{#1}}%
 {\par\hspace*{\fill}\usebox{\storyAuthor}}

\begin{document}

\begin{theStory}{first story}{Author one}
text text text  text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
\end{theStory}

\begin{theStory}{second story\\ {\small\normalfont (my favorite)}}{Author one and Author two}
text text text  text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text 
\end{theStory}

\end{document}
Edit: initially I gave another solution that was poorly designed.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
ddenton
Posts: 34
Joined: Tue Mar 20, 2007 6:08 pm

Re: Orphans and widows

Post by ddenton »

Honestly, I am overwhelmed. This is really an excellent solution. Thank you so much.
Dr. Doerke
Posts: 16
Joined: Sat Dec 06, 2008 7:55 pm

Re: Orphans and widows

Post by Dr. Doerke »

I'm glad I found this posting. It solved my problems. Here's another "thank-you".
Post Reply