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.

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?

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

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!

share|improve this answer
    
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 Mar 28 '12 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. –  Stephan Lehmke Mar 28 '12 at 17:54
add comment

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

share|improve this answer
    
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 Mar 29 '12 at 12:04
add comment

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.