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.

Two questions about customization of ToCs:

  1. My document is numbered the following way: "section"-"page number inside this section". How can I get this numbering style in the ToC?
  2. How to not show the page number of a certain entry in the ToC, more specifically, the bibliography (I'm not sure if it is a special case)?

MWE:

\documentclass[12pt]{article}

\usepackage[numbib,notlof,notlot,nottoc]{tocbibind}
\usepackage{fancyhdr}
\usepackage[top=1in, bottom=1.3in, left=1in, right=1in]{geometry}

\begin{document}

\pagestyle{fancy}
\fancyfoot{}
\fancyfoot[C]{\footnotesize\thepage}

\pagenumbering{roman}
\renewcommand\contentsname{Table of Contents}
\tableofcontents
\listoffigures
\listoftables
\pagebreak

\begin{abstract}
Something...
\end{abstract}

\pagebreak
\fancyfoot[C]{\footnotesize \thesection-\thepage}
\setcounter{page}{1}
\pagenumbering{arabic}
\let\OldSection\section
\renewcommand{\section}[1]{\clearpage\pagenumbering{arabic}\OldSection{#1}\setcounter{subsection}{-1}}

\section{A section}
\subsection{A subsection}
\section{Another section}

\end{document}
share|improve this question
    
Welcome to TeX.sx! No need to add thanks, the preferred way here is to upvote any good answers you may receive; this keeps posts shorter. –  Peter Jansson Feb 28 '13 at 17:41
2  
The answer to your question depends, among other things, on the document class, so please add a minimal working example (MWE) that illustrates your problem. –  lockstep Feb 28 '13 at 17:42
    
@lockstep Thank you, I'll do so. –  João Fernandes Feb 28 '13 at 19:08

1 Answer 1

up vote 2 down vote accepted

My document is numbered the following way: "section"-"page number inside this section". How can I get this numbering style in the ToC?

You have specified the page format only inside fancyfoot. This doesn't influence the the page format itself. To change the page format you can redefine \thepage. Related to your needs

\renewcommand\thepage{\thesection-\arabic{page}}

To use this definition you have to know that the command \pagenumbering changes the definition of \thepage This can be seen in the default definition:

\def\pagenumbering#1{%
  \global\c@page \@ne \gdef\thepage{\csname @#1\endcsname
   \c@page}}

So I recommend the usage of a personal definition of \pagenumbering:

\makeatletter
\def\MyPagenumbering#1{%
   \global\c@page \@ne%page=1 
   \gdef\thepage{\thesection-\csname @#1\endcsname \c@page}%page format
}
\makeatother

How to not show the page number of a certain entry in the ToC, more specifically, the bibliography (I'm not sure if it is a special case)?

A simple way of doing this is the usage of the command \addtocontents{toc}{text}. Of course the formatting of entry must be done by the user.


Here your MWE:

\documentclass[12pt]{article}

\usepackage[numbib,notlof,notlot,nottoc]{tocbibind}
\usepackage{fancyhdr}
\usepackage[top=1in, bottom=1.3in, left=1in, right=1in]{geometry}

\makeatletter
\def\MyPagenumbering#1{%
  \global\c@page \@ne \gdef\thepage{\thesection-\csname @#1\endcsname
   \c@page}}
\makeatother

\begin{document}

\pagestyle{fancy}
\fancyfoot{}
\fancyfoot[C]{\footnotesize\thepage}

\pagenumbering{roman}
\renewcommand\contentsname{Table of Contents}
\tableofcontents
\listoffigures
\listoftables
\pagebreak

\begin{abstract}
Something...
\end{abstract}

\pagebreak
\setcounter{page}{1}
\MyPagenumbering{arabic}
\fancyfoot[C]{\footnotesize\thepage}
\let\OldSection\section
\renewcommand{\section}[1]{\clearpage\MyPagenumbering{arabic}\OldSection{#1}\setcounter{subsection}{-1}}

\section{A section}
\subsection{A subsection}
\section{Another section}

\end{document}
share|improve this answer
    
Marco, thank you a lot, it fixed my first (and most important) question. Regarding the second, sorry for my cumbersome description, I'll try to improve it. Again, thanks! –  João Fernandes Mar 1 '13 at 10:55
    
@JoãoFernandes: I edited my answer. –  Marco Daniel Mar 1 '13 at 11:12

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.