5

I want to put part name in center of TOC as MODULE - I with out page number.

\documentclass{scrbook}
\usepackage[english]{babel}
\usepackage{lipsum}
\usepackage{tocstyle}
\renewcommand{\partname}{Module}%

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


\begin{document}

\tableofcontents

\part{A}
\chapter{chapter A}
\section{Section a}
\lipsum
\part{B}
\chapter{chapter B}
\section{Section b}
\lipsum
\end{document}
3

Instead of redefining l@part you can hack l@part with \addtokomafont:

\addto\captionsenglish is used to redefine the partname. See: Change reports text for bibliography

\documentclass{scrbook}
\usepackage[english]{babel}
\usepackage{lipsum}
\addto\captionsenglish{%
 \renewcommand{\partname}{Module}%
}

\makeatletter
\addtokomafont{partentry}{\def\numberline#1{--~#1\autodot\quad}\centering\partname~}
\addtokomafont{partentrypagenumber}{\let\hfil\relax\def\hb@xt@#1#2{}}
\makeatother
\begin{document}

\tableofcontents

\part{A}
\chapter{chapter A}
\section{Section a}
\lipsum
\part{B}
\chapter{chapter B}
\section{Section b}
\lipsum
\end{document}
1
  • I am not able to format TOC with tocstyle when i use above.
    – sandu
    Jul 4 '13 at 4:50
3

You can redefine \l@part as implemented in scrbook.cls:

\documentclass{scrbook}

\renewcommand\partname{Module}

\makeatletter
\renewcommand*\l@part[2]{%
  \ifnum \c@tocdepth >-2\relax
    \addpenalty{-\@highpenalty}%
    \addvspace{2.25em \@plus\p@}%
    \setlength{\@tempdima}{2em}%
    \if@tocleft
      \ifx\toc@l@number\@empty\else
        \setlength\@tempdima{0\toc@l@number}%
      \fi
    \fi
    \begingroup
      \leavevmode
      \centering\usekomafont{partentry}{\partname\ -- #1\nobreak
        \usekomafont{partentrypagenumber}{}}\null\par
      \ifnum \scr@compatibility>\@nameuse{scr@v@2.96}\relax
      \endgroup
      \penalty20010
      \else
          \penalty\@highpenalty
      \endgroup
    \fi
  \fi
}\makeatother

\begin{document}

\tableofcontents
\part{Test Part One} 
\chapter{Test Chapter}
\section{Test Section}
\part{Test Part Two} 
\chapter{Test Chapter}
\section{Test Section}

\end{document}

enter image description here

5
  • I am not able to format TOC with tocstyle when i use above code.
    – sandu
    Jul 4 '13 at 4:50
  • @sandu that's not enough information. If you want to, you can edit your original question and add there a simple document showing the relevant settings you are using (those for tocstyle`) and showing the problems with the proposed solutions. Jul 4 '13 at 17:20
  • MWE is added in the question
    – sandu
    Jul 5 '13 at 6:15
  • Solution: tex.stackexchange.com/questions/122373/…
    – sandu
    Jul 5 '13 at 6:17
  • @sandu I don't understand. If you already solved the problem, then there's no need for the comments nor for the edit. Please rollback the edit to your question and leave it ss it initially was. Had I known about the other questio I wouldn't have suggested the edit in the first place. Jul 5 '13 at 11:13

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.