3

Here's my code:

\documentclass[]{article}
\usepackage{titlesec}

\begin{document}

\titleformat{\section}
{\normalfont\Large\bfseries}{\thesection}{1em}{}[{\titlerule[0.8pt]}]

\section*{29th March 2014}
\textit{A little subtitle}

Here starts my first paragraph.
\end{document}

Here's a screencap of the resulting document: Resulting document

I'd like the 'little subtitle', being part of the section title, to be situated above the horizontal line.

I assume the easiest way to implement this is to create a section format with two inputs: a "Date" and a "Little subtitle". In this case, my code would then be:

\section*{29th March 2014}{A little subtitle}

How would I go about doing that?

lockstep
  • 250,273
Jeroen
  • 4,491

1 Answers1

4

Here is a solution, using etoolboxand stackengine. I define a \subtitlesec command, with the subtitle as an argument. This command has to be placed before the main title. I didn't check what happens with headers or title of contents, but you always can use the optional argument of section.

    \documentclass[11pt, twoside]{article}% http://ctan.org/pkg/amsproc

    \usepackage[utf8]{inputenc}
    \usepackage[T1]{fontenc}
    \usepackage{lmodern}
    \usepackage{titlesec}
    \usepackage{etoolbox}
    \usepackage{stackengine}

    \newbool{secsub}
    \newcommand{\secsubtitle}[1]{\global\booltrue{secsub}\smash{\brlap{\mdseries\itshape #1}}}

    \titleformat{\section}[hang]{\normalfont\Large\bfseries}{\thesection}{1em}{}[{\titlerule[0.8pt]}{\ifbool{secsub}{\bigskip}{}}\global\setbool{secsub}{false}]%{}
    %
    \titlespacing*{\section}{0ex}{1.8\baselineskip}{1\baselineskip}%

    \begin{document}

    \section{\secsubtitle{A subtitle}First section}

    A section title with a subtitle.

    \section{Another section}

    A section title with no subtitle.

    \end{document} 

enter image description here

Bernard
  • 271,350