Formatting the Table of Contents (Remove “Page”, add periods)

I would like to remove the column heading "Page" from the table of contents. I have looked around and cannot seem to find an answer (or a similar question).

I would also like to add a period "." after only the sections in the table of contents. I have found and tried the following code which produces a period after every entry in the table of contents, not just the sections.

\let \savenumberline \numberline
\def \numberline#1{\savenumberline{#1.}}


Edit: Adding a MWE (hopefully). My document is actually made up of at least 10 separate latex files included by using \input and is still 11,500 lines long. I hope that I have included enough to be helpful. There are items that are commented out just so I didn't lose what "solutions" I had found so far. The foreword is commented out because it was including a list of tables, which was not desired.

I also wanted to add that I noticed that my table of contents is no longer hyperlinking. I'm wondering if this is because I chose "tableofcontents" instead of using the foreword command.

\documentclass[draft,wd,letterpaper]{isov2} % needed to change ; to , in order to compile
\let\ifpdf\relax % required to get rid of fatal error
% Latex Error: /usr/local/texlive/2013/texmf-dist/tex/generic/oberdiek/hobsub-generic.sty:3540 Package ifpdf Error: Name clash, \ifpdf is already defined.

%\usepackage[top=3cm, bottom=3cm, left=3cm, right=3cm]{geometry}

\usepackage{float}
% see http://tex.stackexchange.com/questions/46512/too-many-unprocessed-floats
\usepackage{morefloats}
% see http://www.tex.ac.uk/cgi-bin/texfaq2html?label=underscore
\usepackage{import} % file path
% see http://http://www.ctan.org/pkg/import
\usepackage{multicol}
% see http://www.ctan.org/pkg/multicol

\usepackage{tabularx}
\usepackage{longtable}

% table of contents hyperlinks
\usepackage{hyperref}
\hypersetup{
colorlinks,
citecolor=black,
filecolor=black,
linkcolor=black,
urlcolor=black
}

%\usepackage{lmodern}"
%\usepackage[T1]{fontenc}"
%\usepackage{textcomp}"
%\usepackage{underscore}"

% This bit controls how ASN1 is formatted
\usepackage{listings}
\lstdefinelanguage{ASN1} {
keywords={CHOICE, SEQUENCE, BEGIN, END, IMPLICIT, EXPLICIT, INTEGER, DEFINITIONS},
sensitive=false,
morecomment=[s]{(--}{--)},
morecomment=[l]{--}
}

\lstnewenvironment{asn1}[1][] {
\lstset{
language=ASN1,
tabsize=2,
xleftmargin=1em
captionpos=b,
frame=single,
% basicstyle=\scriptsize,
basicstyle=\footnotesize\ttfamily,
float,
#1
}
}
{}

\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

% essentially allows one to build a table within a table
% \newcommand{\specialcell}[2][c]{%
%   \begin{tabular}[#1]{@{}c@{}}#2\end{tabular}}

% allow underscores to serve as linebreaks for wrapping
\renewcommand\_{\textunderscore\allowbreak}

% defines the command \camelhyphen.  Anything in the argument can break before a capital    letter and wrap with a hyphen
\makeatletter
\def\camelhyphen{\leavevmode\begingroup
\let\ifcase\iftrue
\def\or##1{%
\catcode##1\active\uccode\~##1\uppercase{%
\def~{\egroup\-\hbox\bgroup\string##1}}}%
\@Alph{}%
\@camelhyphen}
\def\@camelhyphen#1{{\hbox\bgroup#1\egroup}\endgroup}
\makeatother

\standard{ISO/IEEE 11073-10201}
\yearofedition{2013}
\languageofedition{(E)}
\setcounter{tocdepth}{3}     % ToC includes ssclauses and above

% Add a period (.) after the section numbering
\makeatletter
\def\@seccntformat#1{\csname the#1\endcsname.\quad}
\makeatother

\usepackage{etoolbox} \patchcmd{\tableofcontents}{\hfil\pagename}{}{}{}

%\usepackage[dotinlabels]{titletoc}

%\usepackage{tocloft}
%\newcommand{\cftdot}{.}
%\let \savenumberline \numberline
%\def \numberline#1{\savenumberline{#1.}}

\usepackage{lipsum}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\title{Example Document}

\newpage
\tableofcontents

\clause{Hello}\lipsum
\sclause{Little}\lipsum
\clause{Second}\lipsum

\end{document}


Clarification: I did not edit my actual .tex file to create a MWE. I did not comment anything out that isn't originally commented in my actual file. The code above creates a similar looking document to what I am working with. I also realize now that I have been referring to clauses as sections, but they are actually clauses.

In the TOC, I would like a period after the clause number only (i.e. not sclause or ssclauses).

@Gonzalo Medina - Thank you very much! That worked beautifully! My TOC now does not show "Page"

Thank you to everyone for your helpful comments.

-
We would need to see the class as well as an example of your usage via a minimal working example (MWE). –  Werner Jul 20 '14 at 4:50
When you say "to add a period "." after only the sections in the table of contents", what exactly are those sections? The isov2 class has \clause, \sclause and similar, Which of those are the ones that you want to add a period to? –  Gonzalo Medina Jul 21 '14 at 1:37
To suppress the word "page" from the ToC, add this to the preamble: \usepackage{etoolbox} \patchcmd{\tableofcontents}{\hfil\pagename}{}{}{} –  Gonzalo Medina Jul 21 '14 at 1:38
Please read the link @Werner provided which explains how to prepare an MWE. Unfortunately, the code you have posted cannot be compiled to reproduce the issue you want help without files 1,...,12 since LaTeX will clearly complain about missing files. By the way, I don't understand why you say you included commented code so that you don't lose stuff. You ought not to modify your own document to create an MWE. Instead, make a copy and modify that. There should be no question whatsoever of deleting any work you've done. An MWE is good for just one thing: posting here to explain your question. –  cfr Jul 21 '14 at 2:42

1 Answer

To suppress the word "page" from the ToC, add these lines to the preamble:

\usepackage{etoolbox}
\patchcmd{\tableofcontents}{\hfil\pagename}{}{}{}


To add a period after the number for clauses in the ToC (but not after) sclauses or other sectional unit entries, a redefinition of \@sect is required; in this redefinition a period is added only if the sectional unit level is one (i.e., the sectional unit is a clause).

The complete code (I deleted from my example some of the packages and code from the code in the question that were not relevant to the problem discussed):

\documentclass[draft,wd,letterpaper]{isov2}
\let\ifpdf\relax
\usepackage{etoolbox}
\usepackage{hyperref}

\hypersetup{
colorlinks,
citecolor=black,
filecolor=black,
linkcolor=black,
urlcolor=black
}

\standard{ISO/IEEE 11073-10201}
\yearofedition{2013}
\languageofedition{(E)}
\setcounter{tocdepth}{3}     % ToC includes ssclauses and above

% Add a period (.) after the section numbering
\makeatletter
\def\@seccntformat#1{\csname the#1\endcsname.\quad}
\makeatother

% suppress ''page'' form the ToC
\patchcmd{\tableofcontents}{\hfil\pagename}{}{}{}

% Add a perior after clause number in ToC
\makeatletter
\def\@sect#1#2#3#4#5#6[#7]#8{%
\ifnum #2>\c@secnumdepth
\let\@svsec\@empty
\else
\refstepcounter{#1}%
\protected@edef\@svsec{\@seccntformat{#1}\relax}%
\fi
\@tempskipa #5\relax
\ifdim \@tempskipa>\z@
\begingroup
#6{%
\@hangfrom{\hskip #3\relax\@svsec}%
\interlinepenalty \@M #8\@@par}%
\endgroup
\csname #1mark\endcsname{#7}%
\addcontentsline{toc}{#1}{%
\ifnum #2>\c@secnumdepth \else
\ifnum#2=1\relax
\protect\numberline{\csname the#1\endcsname.}%
\else
\protect\numberline{\csname the#1\endcsname}%
\fi
\fi
#7}%
\else
\@xsect
\def\@svsechd{%
#6{\hskip #3\relax
\@svsec #8}%
\csname #1mark\endcsname{#7}%
\addcontentsline{toc}{#1}{%
\ifnum #2>\c@secnumdepth \else
\protect\numberline{\csname the#1\endcsname}%
\fi
#7}}%
\fi
\@xsect{#5}}
\makeatother

\begin{document}

\title{Example Document}

\newpage
\tableofcontents

\clause{First test clause}
test
\sclause{Test sclause}
test
\ssclause{Test ssclause}
test
\clause{Second test clause}
test

\end{document}


The result:

-
you are awesome! I have a related question - I have noticed that my ToC is no longer "clickable". I have the hypperref package included. When you were able to create your test document, was your table of contents hyperlinking? –  Khori Wood Aug 5 '14 at 16:39
@KhoriWood there are no hyperlinks because you have the class option draft in \documentclass[draft,wd,letterpaper]{isov2}; delete draft` and you'll have the hyperlinks back. –  Gonzalo Medina Aug 5 '14 at 17:18