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.

Is it possible to use lists WITHIN section headings, subsection headings, etc.? I wanted to do so like

\documentclass[11pt]{scrartcl}
\usepackage{enumerate}
%...
\begin{document}

\section{My three favorite flowers are:
 \begin{enumerate}
  \item Roses
  \item Daysies
  \item Violets
 \end{enumerate}
Now I will tell you stuff about them}

\end{document}

but it doesn't compile. Error is:

Argument of \@sect has an extra }.
<inserted text> 
                \par 
share|improve this question
    
What do you mean "it doesn't compile"? What is the error message you receive? Can you provide an MWE starting at \documentclass{...} and ending with \end{document} please? –  darthbith Jun 16 at 15:22
5  
And why exactly do you want this? –  daleif Jun 16 at 15:22
1  
you mean within section headings; please change the text of your title and the description to make this clear. (and, like daleif, i wonder why you want this.) –  barbara beeton Jun 16 at 15:29
5  
Section titles should be as short as possible, without hindering comprehension. An enumerated list in a section title is out of question, in my opinion. –  egreg Jun 16 at 15:35
1  
I know it is very odd to do something like that. There are definately better solutions to do this, but I wanted to make an written report ("Ausarbeitung") which answers a great number of specific questions. Most of those questions have lists in them, and I wanted to cite them in the sections, so they are easy to find with the table of contents. @Werner Your comment gave me the idea to use \section[Name in Table of Contents]{...} Apparently LaTeX did try to put the list in the ToC, which understandably didn't work. –  Josephus Jun 16 at 15:48

2 Answers 2

up vote 5 down vote accepted

The argument of sectional units are fragile and therefore can only contain a limited number of things, unless you're careful. A way out of your situation - against all common uses - is to keep your list inside the section, but provide an alternative "floating argument". This is provided by the optional argument:

enter image description here

\documentclass{scrartcl}
\begin{document}

\section[My three favourite flowers]{My three favourite flowers are:
 \begin{enumerate}
  \item Roses
  \item Daisies
  \item Violets
 \end{enumerate}
Now I will tell you stuff about them}

\end{document}

If, however, you're only after the sectional unit font, then you can define that and use it accordingly:

enter image description here

\documentclass{scrartcl}
\makeatletter
\newenvironment{SECTION}
  {\sectfont\size@section\noindent\ignorespaces}% \begin{SECTION}
  {}% \end{SECTION}
\makeatother
\begin{document}

\begin{SECTION}
My three favourite flowers are:
 \begin{enumerate}
  \item Roses
  \item Daisies
  \item Violets
 \end{enumerate}
Now I will tell you stuff about them
\end{SECTION}

\end{document}

You could even add the section number to it by perhaps using

\makeatletter
\newenvironment{SECTION}
  {\refstepcounter{section}%
   \sectfont\size@section\noindent%
   \thesection\quad\ignorespaces}% \begin{SECTION}
  {}% \end{SECTION}
\makeatother

Of course, this would remove all sectional functionality, but I'm not sure whether this is required in your instance.


To match Steven's stack, you can also use this definition:

enter image description here

\documentclass{scrartcl}
\begin{document}

\tableofcontents

\section{\protect\tabular[t]{@{}l}
  My three favourite flowers are: \\
  ~~1. Roses \\
  ~~2. Daisies \\
  ~~3. Violets \\
  Now I will tell you stuff about them
  \protect\endtabular}

\end{document}

The \protection allows for safer travel of fragile arguments.

share|improve this answer
    
It works! Thank you very much for your time and effort, your different ways of accomplishing my goal, and your clean, structured, and educational writing. –  Josephus Jun 16 at 18:02

You can fake it with a stack:

\documentclass[11pt]{scrartcl}
\usepackage{enumerate}
\usepackage[usestackEOL]{stackengine}
\begin{document}
\tableofcontents

\section{\Longunderstack[l]{
My three favorite flowers are:\\
  ~~1. Roses\\
  ~~2. Daysies\\
  ~~3. Violets\\
Now I will tell you stuff about them
}}
Does it work?
\section{Blah Blah}
More stuff
\end{document}

enter image description here

share|improve this answer
    
This is magnificent! Unfortunatley I don't have the package in TeXLive 2012. "LaTeX Error: File `stackengine.sty' not found." Do I need to use a newer version? –  Josephus Jun 16 at 16:10
1  
@Josephus You can download the sty file and documentation at ctan.org/pkg/stackengine –  Steven B. Segletes Jun 16 at 16:13

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.