1

In the \documentclass{tufte-book}

The normal header for Chapter would be

\chapter{6}

etc. But how can I get the chapter number to display as an auto counter, without having to fill in that actual number. I know that chapter has a counter already associated with it, but if you just leave the brackets empty it obviously doesn't print the chapter number.

(I'm moving chapters around so want to have the counter display without having to change the whole string of chapter numbers every time a chapter gets broken apart. as far as I understand, I can't put a command inside the brackets like

\chapter{\counter}
2

Edit after @DavidCarlisle's comment about refstepcounter:

\newcounter{mychapter}

\newcommand{\aasc}{\refstepcounter{mychapter}\let\newtitle\themychapter}
\newcommand{\mychapter}[1]
{%
\aasc%
\ifnum\pdfstrcmp{#1}{}=0
\chapter{\newtitle.}%
\else
\chapter{\newtitle.\space #1}%
\fi
}

It works with labels and refs now... Thanks @DavidCarlisle...

OldAnswer

Try this in your preamble:

\newcommand{\aasc}{\addtocounter{chapter}{1}\let\newtitle\thechapter}
\newcommand{\mychapter}[1]
{
\aasc
\ifnum\pdfstrcmp{#1}{}=0
\chapter{\newtitle.}
\else
\chapter{\newtitle.\space #1}
\fi
}

It works for empty or non-empty chapters... but empty has to not contain even a space...

  • it would be better to use \restepcounter{chapter} so you can use \label, rather than \addtocounter{chapter}{1} – David Carlisle Jul 3 '17 at 19:38
  • thanks @DavidCarlisle... checking your command... I thought it was \stepcounter... – koleygr Jul 3 '17 at 19:46
  • 1
    no \stepcounter would just do the same as you have, you want \refstepcounter (you are also missing several % from ends of lines) – David Carlisle Jul 3 '17 at 19:47
  • why the newcounter? – David Carlisle Jul 3 '17 at 20:18
  • 1
    If you pushed me I could generate an example where the missing % causes a blank page:-) – David Carlisle Jul 3 '17 at 20:59
4

The argument to \chapter is intended to be the title not a number. As in most classes chapters are numbered automatically.

However the tufte class sets section numbering off by the default as part of its style, you can allow chapters and sections to be numbered by setting

\setcounter{secnumdepth}{2}

However the design is really based around unnumbered headings so an alternative would be to use a class designed for numbered headings. However with the above line, you get

enter image description here

\documentclass{tufte-book}

\setcounter{secnumdepth}{2}
\begin{document}

\mainmatter
\chapter{Intro}
\section{zzzz}
zzzz
\chapter{Something}
\section{zzzz}
zzzz

\end{document}
  • Is there a way to use {secnumdepth} and set it to start at 0, not 1? i.e. a chapter 0 (I know I can supress the number with the *, but I don't want just an unnumbered chapter, but specifically 0) – L.H. Draken Jul 5 '17 at 7:33
  • \setcounter{chapter}{-1} anywhere before the first chapter – David Carlisle Jul 5 '17 at 8:11
2

enter image description here

enter image description here

Use the package cleveref and in the preamble you can customize your referencing as you wish. For me I use the following customization for chapters:

\crefname{chapter}{Chapter}{Chapters}
\Crefname{chapter}{Chapter}{Chapters}
\crefformat{chapter}{Chapter #1}
\crefrangeformat{chapter}{#1}

Note that you can replace Chapter and Chapters with abbreviated forms such as Ch. You can also further customize the numbering by adding a dot like \crefformat{chapter}{Chapter. #1} or brackets like \crefformat{chapter}{Chapter. (#1)} which will automatically put brackets for chapter numbers. Here is a sample code:

\documentclass[]{report}


\usepackage{cleveref}

% Define formats
\crefname{chapter}{Chapter}{Chapters}
\Crefname{chapter}{Chapter}{Chapters}
\crefformat{chapter}{Chapter #1}
\crefrangeformat{chapter}{#1}



\begin{document}



\chapter{First Chapter}
\label{ch:first}
For more information about this topic please refer to \cref{ch:fifth,,ch:third,,ch:fourth}


\chapter{Second Chapter}
\label{ch:second}
In \cref{ch:first}, we introduced (topic name). Here, we address the problem in more detail.


\chapter{Third Chapter}
\label{ch:third}


\chapter{Fourth Chapter}
\label{ch:fourth}


\chapter{Fifth Chapter}
\label{ch:fifth}



\end{document}

The beauty of \cref command is that it handles the order of referenced chapters, sections, or floats automatically. For instance, I deliberately wrote \cref{ch:fifth,,ch:third,,ch:fourth} where the fifth chapter is put first in the referencing, but still, \cref shows them in their order of appearance after you compile the document.

  • 2
    you have not used the tufte-book class though, which is the point of the question (as it does not number chapters by default) – David Carlisle Jul 3 '17 at 19:36
  • @DavidCarlisle It also seems that he does not know how to reference chapters systematically: "I'm moving chapters around so want to have the counter display without having to change the whole string of chapter numbers every time a chapter gets broken apart." – Al-Motasem Aldaoudeyeh Jul 3 '17 at 22:29

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.