0

I've used this site to find how to remove section numbering, and to put my table of contents into two columns, however there is one thing I want to do.

My table of contents currently says 'Contents' at the top. If I want to remove this, or use my own heading, how do I do this?

My document is set up as follows:

\documentclass[10pt, twoside, twocolumn]{book}

\usepackage[a4paper, inner=2cm, outer=1cm, top=1.5cm, bottom=1.5cm]{geometry}

\usepackage{pgffor}

\makeatletter
\newcommand{\twocolumntoc}{%
  \chapter*{\contentsname
    \@mkboth{%\MakeUppercase\contentsname}{\MakeUppercase\contentsname}}%
  \@starttoc{toc}%
}
\makeatother

\setcounter{secnumdepth}{-1}

\begin{document}
% set font for entire document
\fontfamily{qhv}\selectfont
\twocolumntoc
\section{Introduction}
\end{document}
  • 2
    The answer depends on the used class and packages related to the table of contents. So without a minimal but working example (MWE) that gives us such essential informations, the question is quiet broad. And please ask only one question per question! – Schweinebacke Nov 8 '17 at 11:46
  • @Schewinebacke Removed a question, and included a MWE as requested. Hope this helps. – C. de Haer Nov 9 '17 at 9:49
  • Please make your example compilable! – Schweinebacke Nov 10 '17 at 7:40
2

Your example is not compiling without error, because of misplaced comment char %. But I seems you are searching either

\documentclass[10pt, twoside, twocolumn]{book}

\usepackage[a4paper, inner=2cm, outer=1cm, top=1.5cm, bottom=1.5cm]{geometry}

\usepackage{pgffor}

\makeatletter
\newcommand{\twocolumntoc}{%
%  \chapter*{\contentsname
%    \@mkboth{%\MakeUppercase\contentsname}{\MakeUppercase\contentsname}}%
  \@starttoc{toc}%
}
\makeatother

\setcounter{secnumdepth}{-1}

\begin{document}
% set font for entire document
\fontfamily{qhv}\selectfont
\twocolumntoc
\section{Introduction}
\end{document}

Or

\documentclass[10pt, twoside, twocolumn]{book}

\usepackage[a4paper, inner=2cm, outer=1cm, top=1.5cm, bottom=1.5cm]{geometry}

\usepackage{pgffor}

\renewcommand*{\contentsname}{This is my contents heading}
\makeatletter
\newcommand{\twocolumntoc}{%
  \chapter*{\contentsname
    \@mkboth{\MakeUppercase\contentsname}{\MakeUppercase\contentsname}}%
  \@starttoc{toc}%
}
\makeatother

\setcounter{secnumdepth}{-1}

\begin{document}
% set font for entire document
\fontfamily{qhv}\selectfont
\twocolumntoc
\section{Introduction}
\end{document}

Note: Redefining \contentsname in the document preamble does not work as shown above, if you are using babel. See the babel manual for more information about changing language depending terms.

BTW: Setting a sanserif font for the entire document shouldn't be done using \fontfamily at the beginning of the document. This would not change the font of elements, that use \normalfont. You should instead redefine \familydefault. qhv is TeX Gyre Heros. There is a package to use it. So you can use:

\documentclass[10pt, twoside, twocolumn]{book}

\usepackage[a4paper, inner=2cm, outer=1cm, top=1.5cm, bottom=1.5cm]{geometry}

\usepackage{pgffor}
\usepackage{tgheros}
\renewcommand\familydefault{\sfdefault}% use TeX Gyre Heros for entire documente

\renewcommand*{\contentsname}{This is my contents heading}
\makeatletter
\newcommand{\twocolumntoc}{%
  \chapter*{\contentsname
    \@mkboth{\MakeUppercase\contentsname}{\MakeUppercase\contentsname}}%
  \@starttoc{toc}%
}
\makeatother

\setcounter{secnumdepth}{-1}

\begin{document}
\twocolumntoc
\section{Introduction}
\end{document}

Additional note because of a comment: If you do not use \chapter* in your document, you are using the wrong class. In this case, article instead of book would be better and you wouldn't need \twocolumntoc:

\documentclass[10pt, twoside, twocolumn]{article}
\usepackage[a4paper, inner=2cm, outer=1cm, top=1.5cm, bottom=1.5cm]{geometry}
\usepackage{tgheros}
\renewcommand\familydefault{\sfdefault}% use TeX Gyre Heros for entire documente

\renewcommand*{\contentsname}{This is my contents heading}
\setcounter{secnumdepth}{-1}% Don't use section numbering
\usepackage{mwe}% useful only for demonstration

\begin{document}
\tableofcontents
\blinddocument
\end{document}

using article

  • Excellent - I didn't even know changing the font for the entire document. Works well. I have included the contents name, but how do I change the size of the font used for it, so it is consistent with other headings in the document? – C. de Haer Nov 10 '17 at 1:05
  • @C.deHaer Aren't you using \chapter for headings? Then you are using the wrong class. Using article makes things very, very easy in this case. See the last example in the edited answer. – Schweinebacke Nov 10 '17 at 7:39

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.