2

In the screenshot blue, is it possible to replace the this ( I ) preceding the name of the part by (Part I) ?!. enter image description here

Here is my MWE:

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage[utf8]{inputenc}

\begin{document}

\tableofcontents

\addtocontents{toc}{\smallskip \hrule height 3pt \vspace{-4.5ex} \vspace{0.2cm}  }
\part{Differential Forms}
\addtocontents{toc}{{ }}
\addtocontents{toc}{\vspace{0.2cm} \nobreak\smallskip \hrule height 2.5pt }
\end{document}
  • Please post compilable examples. And you had questions similar to this, with tocloft included. Using that package it's quite to achieve this! – user31729 Aug 25 '16 at 15:23
  • I didn’t understand what you mean by "compilable examples". Besides, this is a different question ! – Hussein Eid Aug 25 '16 at 15:26
  • Your document is a fragment only. It misses \end{document} – user31729 Aug 25 '16 at 15:26
  • I edited the post. – Hussein Eid Aug 25 '16 at 15:27
3

A solution with titlesec and titletoc:

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{geometry}
\usepackage[svgnames]{xcolor}

\usepackage{titlesec}
\usepackage{titletoc}
\usepackage[hidelinks]{hyperref}

\titleformat{\part}[display]
  {\scshape\filcenter}
  {\large\partname~\thepart}
  {2ex}
  {\Large}
  [\vspace{5ex}]

\titlecontents{part}[0pt]
  {\bfseries\protect\addvspace{15pt}\titlerule[1pt]\addvspace{1.2ex}}
  {}
  {\color{RoyalBlue}\partname~}%numbered, unnumbered
  {\hfill\contentspage}
  [\addvspace{0.7ex}{\titlerule[1pt]}\addvspace{1.5ex}]

\begin{document}

\tableofcontents

\part{Beginnings}

\section{Things}

\section{More Things}

\end{document} 

enter image description here

3

Use tocloft for example and redefine \cftpartpresnum to contain the word Part (or whatever \partname yields). In order to prevent clashes with the part number, increase the width of the number box with \addtolength{\cftpartnumwidth}{20pt} (The value of 20pt is just a guess, nothing more!)

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage[utf8]{inputenc}
\usepackage{tocloft}

\renewcommand{\cftpartpresnum}{\partname{} }
\addtolength{\cftpartnumwidth}{20pt}

\begin{document}

\tableofcontents

\addtocontents{toc}{\smallskip \hrule height 3pt \vspace{-4.5ex} \vspace{0.2cm}  }
\part{Differential Forms}
\addtocontents{toc}{{ }}
\addtocontents{toc}{\vspace{0.2cm} \nobreak\smallskip \hrule height 2.5pt }
\end{document}

enter image description here

  • The indents of toc entries might have to be extended as well... – user31729 Aug 25 '16 at 15:34

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.