6

I'm trying to work out the best way to create a section-like command that has two options associated to it with mixed formatting of the result. Specifically:

\alternativesection{Section title}{Subtitle}

should produce something like:

Section title [Subtitle]

(i.e., there will be a mix of formatting on the section title line).

[My real example will not actually be mixing boldface and italic, more likely different sizes of font, but these two illustrate hopefully clearly the principal and if they can be achieved then I can try the slightly more typographically reasonable thing that I'm really hoping for.]

I couldn't see how to use \@startsection to achieve this and the titlesec package doesn't seem to permit this mixture of formatting. Is there some other package that does this sort of thing or is it necessary to do some lower-level hacking copying the original definition of \@startsection.

[I'm using pdfLaTeX, not XeTeX nor LuaLaTeX.]

  • 1
    Use xparse to create the various options for it. – daleif Oct 4 '13 at 8:06
6

A simple definition would apparently be:

\newcommand\alternativesection[2]{\section[#1]{#1 [\textit{#2}]}

Or you could replace \section by its equivalent underlying call to \@startsection which would give a bit more flexibility.

  • Thanks David - that was much easier than I thought. Since I wanted to change font as well, I needed a \normalfont in addition, but this was exactly the pointer I needed. – Martyn Quick Oct 4 '13 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.