1

so in making ToC, \contentslabel gives you the section number, and using \thecontentslabel give you the default format. The problem is that this number is in arabic, while I want to use roman. Titletoc gave \contentslabel[<format>] to reformat this, but it doesn't tell me the wanted format. Any way to reformat it to roman numbering ?

My code is :

\documentclass[oneside,12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{titlesec}
\usepackage{titletoc}

\titleformat{\chapter}[display]{\bfseries\upshape\filcenter}{CHAPTER \ \Roman{chapter}}{1ex}{} \titlespacing*{\chapter} {0pt}{-10pt}{40pt}

\titlecontents{chapter}[0pt]{\bfseries}%above code {\MakeUppercase{\chaptername} \thecontentslabel \ }%numbered chapter% {}%numberless chapter% {\mdseries\titlerule*[0.75em]{.}\bfseries\thecontentspage}%for dots

\chapter{lorem} \chapter{ipsum}

As you can see I format my chapter with roman, but \thecontentslabel still gives arabic. Format I want :

CHAPTER I LOREM
CHAPTER II IPSUM

the default output:

CHAPTER 1 LOREM
CHAPTER 2 IPSUM

some of my tried format(all fail):

\titlecontents{chapter}[0pt]{\bfseries}%above code
{\MakeUppercase{\chaptername} \contentslabel[\Roman{contentslabel}] \ }%numbered chapter%
{}%numberless chapter%
{\mdseries\titlerule*[0.75em]{.}\bfseries\thecontentspage}%for dots

\titlecontents{chapter}[0pt]{\bfseries}%above code {\MakeUppercase{\chaptername} \contentslabel[\Roman{\contentslabel}] \ }%numbered chapter% {}%numberless chapter% {\mdseries\titlerule*[0.75em]{.}\bfseries\thecontentspage}%for dots

\titlecontents{chapter}[0pt]{\bfseries}%above code {\MakeUppercase{\chaptername} \Roman{\thecontentslabel} \ }%numbered chapter% {}%numberless chapter% {\mdseries\titlerule*[0.75em]{.}\bfseries\thecontentspage}%for dots

\titlecontents{chapter}[0pt]{\bfseries}%above code {\MakeUppercase{\chaptername} \Roman{thecontentslabel} \ }%numbered chapter% {}%numberless chapter% {\mdseries\titlerule*[0.75em]{.}\bfseries\thecontentspage}%for dots

1 Answers1

0

Here is a solution based on the TeX primitive \romannumeral:

\documentclass[oneside,12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{titlesec}
\usepackage{titletoc}

\titleformat{\chapter}[display]{\bfseries\upshape\filcenter}{CHAPTER \ \Roman{chapter}}{1ex}{} \titlespacing*{\chapter} {0pt}{-10pt}{40pt}

\titlecontents{chapter}[0pt]{\bfseries}%above code {\MakeUppercase{\chaptername\ \romannumeral \thecontentslabel}\enspace}%numbered chapter% {}%numberless chapter% {\mdseries\titlerule*[0.75em]{.}\bfseries\thecontentspage}%for dots

\begin{document}

\tableofcontents \chapter{lorem} \chapter{ipsum}%

\end{document}

enter image description here

Bernard
  • 271,350