14

I would like to refer to my chapters with the notation "First Chapter", "Second Chapter" etc, rather than "Chapter 1", "Chapter 2", etc. How can I do this?

\documentclass{scrreprt}

\usepackage[english]{babel} 
%Loaded here: microtype,graphicx,booktabs,caption,tabularx,hyperref,amsmath
\usepackage{classicthesis-preamble}
\usepackage{classicthesis}

% A personalization of description environment
\renewcommand{\descriptionlabel}[1]{\hspace*{\labelsep}\small\textsc{#1}}

\begin{document}
\chapter{MyChapter}
\label{ch:first}

\begin{description}
\item [In the \ref{ch:first}] I yada yada yada
\end{description}

\end{document}

2 Answers 2

15

The right package to use, along with refcount, is numname:

\usepackage{refcount,numname}
\newcommand{\refc}[1]{\ordinaltoName{\getrefnumber{#1}} Chapter}

In the \refc{ch:first} we do something.

To get also a link,

\newcommand{\refc}[1]{\hyperref[#1]{\ordinaltoName{\getrefnumber{#1}} Chapter}}
4
  • Also here, the text is ok but it doesn't link to the chapter.
    – Baduel
    Dec 14, 2011 at 13:35
  • @Baduel See edited message
    – egreg
    Dec 14, 2011 at 13:39
  • Thanks. How can I have the same result with the Appendix?
    – Baduel
    Dec 14, 2011 at 14:25
  • 1
    I've found the answer: \autoref =)
    – Baduel
    Dec 14, 2011 at 14:27
8

You may use something like

\documentclass{scrreprt}

\usepackage[english]{babel} 
%Loaded here: microtype,graphicx,booktabs,caption,tabularx,hyperref,amsmath
\usepackage{classicthesis-preamble}
\usepackage{classicthesis}

% A personalization of description environment
\renewcommand{\descriptionlabel}[1]{\hspace*{\labelsep}\small\textsc{#1}}

\usepackage{refcount}
\newcommand*{\refc}[1]{%
  \setrefcountdefault{0}%

  \hyperref[#1]{\ifcase\getrefnumber{#1}
  ???
  \or First
  \or Second
  \or Third
  % please extend this on your own
  \else A kind of yellow
  \fi Chapter}}

\begin{document}
\chapter{MyChapter}
\label{ch:first}

\begin{description}
\item [In the \refc{ch:first}] I yada yada yada
\end{description}

\end{document}

to do this. There's also a package engord for english ordinals, that may be used instead of a \ifcase construct.

Alternative you may patch \refstepcounter and redefine \p@chapter to make all \ref to a chapter to be text references:

\documentclass{scrreprt}

\usepackage[english]{babel} 
%Loaded here: microtype,graphicx,booktabs,caption,tabularx,hyperref,amsmath
\usepackage{classicthesis-preamble}
\usepackage{classicthesis}

% A personalization of description environment
\renewcommand{\descriptionlabel}[1]{\hspace*{\labelsep}\small\textsc{#1}}

\makeatletter
% 1. Allow \p@… to be a command with an argument
\renewcommand*\refstepcounter[1]{\stepcounter{#1}%
  \protected@edef\@currentlabel
  {\csname p@#1\expandafter\endcsname\csname the#1\endcsname}%
}
% Then ignore this argument at `\p@chapter` and use the completely different
% output instead.
\renewcommand\p@chapter[1]{\ordinalnumbertext{\value{chapter}} \@chapapp}%
\makeatother

\newcommand*{\ordinalnumbertext}[1]{%
  \ifcase#1
  ???
  \or First
  \or Second
  \or Third
  \else A kind of yellow
  \fi
}

\begin{document}
\chapter{MyChapter}
\label{ch:first}

\begin{description}
\item [In the \ref{ch:firsta}] I yada yada yada
\end{description}

\appendix
\chapter{MyChapter}
\label{ch:firsta}

\begin{description}
\item [In the \ref{ch:first}] I yada yada yada
\end{description}
\end{document}

This does even work with appendices like shown in the example.

2
  • The text is right, but refc doesn't refer!
    – Baduel
    Dec 14, 2011 at 12:25
  • @Baduel: It did refer but it didn't link to. I've changed the first example, to solve this. The second links too. Dec 14, 2011 at 12:33

You must log in to answer this question.

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