8

This is going to be a little complicated: in the spirit of Bringhurst I am trying to incorporate italic ampersands into headings. I am using a LuaLaTeX modified version of classicthesis, hence the layout is relatively complex. I hope the following illustrates the problem. I tried to generate an MWE, but the table of content generation of classicthesis is a little to complex for me.

classicthesis uses spaced capitals for chapter headings and small caps for section headings. The normalsized ampersand is fine for chapters, but to large for for sections. I created two versions \amper and \ampersmall:

\newcommand{\amper}{\protect\textit{\&}\xspace}
\newcommand{\ampersmall}{\protect\footnotesize\textit{\&}\xspace\normalsize}

The result is fine in the text:

Chapter with large ampersand

Chapter heading

Section with small ampersand Section heading

The problem is the table of contents, because here they layout is the opposite: chapter headings are in small caps and section headings are in normal text: TOC

Hence, I would like the exact opposite in the TOC: small ampersand for chapters, normal ampersand for sections.

Does anyone has a suggestion how to accomplish switching the ampersand-macros in the TOC?

2 Answers 2

8

It's generally not a good idea to put font-dependent stuff into moving arguments, because as you see, things can get formatted differently in different places.

I tried to

  1. Check whether the current font is small caps and
  2. use a relative size change.

The result:

\documentclass{article}

\usepackage{xspace}
\usepackage{relsize}

\newcommand*\scname{sc}

\makeatletter
\DeclareRobustCommand{\amper}{%
  \ifx\f@shape\scname
    {\smaller\textit{\&}}%
   \else
     \textit{\&}%
  \fi
\xspace}
\makeatother

\begin{document}

\textbf{cat \amper dog}
\textsc{cat \amper dog}

\end{document}

Enjoy!

2
  • Thanks, on first glance that appears to be working perfectly. I'll check more thoroughly if it breaks stuff at certain places. Concerning your first comment (font-dependent stuff in moving arguments), can this be overcome regarding this issue?
    – Jörg
    Commented Mar 28, 2012 at 17:53
  • I tried to overcome it in the sense of making a definition which reacts to the font configuration at hand, but in the end you're always bound to forsee what variance the context may have. Commented Mar 28, 2012 at 17:54
4

This does not directly answer your question, but how about using different definitions for \amper & friends in the ToC vs. everywhere else? Example:

\documentclass{article}

\usepackage{xcolor}

\DeclareRobustCommand{\strong}[1]{\textcolor{red}{#1}}

\DeclareRobustCommand{\renewstrong}{%
  \DeclareRobustCommand{\strong}[1]{\textcolor{blue}{##1}}%
}

\AtBeginDocument{\addtocontents{toc}{\renewstrong}}

\begin{document}

\tableofcontents

\section{A section with a special \strong{emphasis}}

\end{document}

enter image description here

1
  • That works as well and is probably more robust than the answer from @stephan-lehmke, but his approach has the advantage of needing only one \amper command that adjusts automatically, while different definitions require one for large and one for small (as I originally stated). Stephan's approach appears to be stable with classicthesis, hence I am going for that.
    – Jörg
    Commented Mar 29, 2012 at 12:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .