3

I want to remove page number in TOC entry for Part (in this example 3 must be removed)

\documentclass{scrbook}

\usepackage{lmodern}% for sans-serif plus bold plus italic

\renewcommand\partname{Module}

\usepackage{tocstyle}
\usetocstyle{standard}
\usetocstyle{nopagecolumn}
\settocstylefeature{pagenumberhook}{\itshape}

\settocfeature{pagenumberhook}{~}
\renewcommand*{\addparttocentry}[2]{%
  \addtocentrydefault{part}{}{\protect\parbox{\textwidth}{\protect\centering#2}}% original #1 in second argument
}

\usepackage{blindtext}


\begin{document}

\tableofcontents

\part{First Module}

\blinddocument

\end{document}

Answer update from lockstep answer

\documentclass{scrbook}
\usepackage{lmodern}% for sans-serif plus bold plus italic

\renewcommand\partname{Module}

\usepackage{tocstyle}
\usetocstyle{standard}
\usetocstyle{nopagecolumn}
\settocstylefeature{pagenumberhook}{\itshape~}
\makeatletter
\settocstylefeature[-1]{pagenumberhook}{\@gobble}
\makeatother

\renewcommand*{\addparttocentry}[2]{%
  \addtocentrydefault{part}{}{\protect\parbox{\textwidth}{\protect\centering Module #1 ~--~ #2}}% original #1 in second argument
}

\usepackage{blindtext}

\begin{document}

\tableofcontents

\part{First Module}

\blinddocument

\part{Second Module}

\blinddocument
\end{document}

enter image description here

2
  • Please consider to accept marco Daniel's answer instead of my one.
    – lockstep
    Jul 4 '13 at 8:06
  • @lockstep "Module" is missing in front of the part number i need it.
    – sandu
    Jul 5 '13 at 6:38
4

All your requirements can be achieve by tocstyle without any redefinitions of internal commands with the the following two lines:

\settocstylefeature[-1]{entryhook}{\hfil}%centering part entry
\settocstylefeature[-1]{pagenumberbox}{\csname @gobble\endcsname}%no page numbers for part

Here the complete MWE:

\documentclass{scrbook}

\usepackage{lmodern}% for sans-serif plus bold plus italic

\renewcommand\partname{Module}

\usepackage{tocstyle}
\usetocstyle{standard}
\usetocstyle{nopagecolumn}
\settocstylefeature[-1]{entryhook}{\hfil}%centering part entry
\settocstylefeature[-1]{pagenumberbox}{\csname @gobble\endcsname}%no page numbers for part

\settocstylefeature{pagenumberhook}{\itshape~}

\usepackage{blindtext}

\begin{document}

\tableofcontents

\part{First Module}

\blinddocument

\end{document}

Some modifications related to the comments of the OP.

\documentclass{scrbook}
\usepackage{lmodern}% for sans-serif plus bold plus italic

\renewcommand\partname{Module}

\usepackage{tocstyle}
\usetocstyle{standard}
\usetocstyle{nopagecolumn}
\settocstylefeature[-1]{entryhook}{\hfil\partname\space}%centering part entry
\settocstylefeature[-1]{pagenumberbox}{\csname @gobble\endcsname}%no page numbers for part
\settocstylefeature[0]{leaders}{\hfill}%
\settocstylefeature{pagenumberhook}{\itshape~}

\usepackage{blindtext}

\begin{document}

\tableofcontents

\part{First Module}

\blinddocument

\end{document}

enter image description here

3
  • Nice solution, is it possible to make nopagecolumn does not change the chapter page number. Only for chapters page number must be printed at the right.
    – sandu
    Jul 5 '13 at 6:20
  • "Module" is missing in front of the part number.
    – sandu
    Jul 5 '13 at 6:27
  • @sandu: I implemented all. Jul 5 '13 at 8:49
3

\settocstylefeature[-1]{pagenumberhook}{\@gobble} does the trick. Note that the last of multiple \settocstylefeature instructions for the same level overrides the others.

\documentclass{scrbook}

\usepackage{lmodern}% for sans-serif plus bold plus italic

\renewcommand\partname{Module}

\usepackage{tocstyle}
\usetocstyle{standard}
\usetocstyle{nopagecolumn}
\settocstylefeature{pagenumberhook}{\itshape~}
\makeatletter
\settocstylefeature[-1]{pagenumberhook}{\@gobble}
\makeatother

\renewcommand*{\addparttocentry}[2]{%
  \addtocentrydefault{part}{}{\protect\parbox{\textwidth}{\protect\centering#2}}% original #1 in second argument
}

\usepackage{blindtext}

\begin{document}

\tableofcontents

\part{First Module}

\blinddocument

\end{document}

enter image description here

3
  • Thanks. Can we add Module - I in the part title. Sample part title: "Module - I First Module"
    – sandu
    Jul 4 '13 at 6:20
  • 1
    \renewcommand*{\addparttocentry}[2]{% \addtocentrydefault{part}{}{\protect\parbox{\textwidth}{\protect\centering Module #1 ~--~ #2}} Gives what i want.
    – sandu
    Jul 4 '13 at 6:24
  • @sandu Nice -- I'm not familiar with \addparttocentry.
    – lockstep
    Jul 4 '13 at 6:27

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.