1

I have seen the answer to a similar question, but I want more control:

I have roman Chapters and arabic sections. I want the roman numeral to be hidden from the TOC, and from the TOC only (additionally, I will also remove them later from the section titles). The most important is that I need the cross chapter section references to show the chapter number.

I tried titletoc without success (although copying almost identically a command from the manual):

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

\renewcommand{\thechapter}{\Roman{chapter}}
\newcommand{\thesectiononly}{\arabic{section}}  % Do not override \thesection.

% Large bold section titles with section number only
\titleformat{\section}{\Large\bfseries}{\thesectiononly}{24pt}{}

% bold section names in the table of contents, with section number only.
\titlecontents*{section}[12pt]{\bfseries}{\thesectiononly. }{}{\thecontentspage}

\begin{document}

% Here, we should see 1. First section......
\tableofcontents

\chapter{First chapter}

\section{First section}\label{sec:first-section}

First content.

\section{Second section}

Other content.

\chapter{Second chapter}

\section{section in second chapter}

Last content, referring to section~\ref{sec:first-section}. % Displayed as "I.1"

\end{document}

This compiles, but the resulting TOC is:

Imgur

  • How do I get the correct section numbering?
  • How do I get default leading dots to the page number?

I know about tocloft, but haven't found a way to strip off chapter numbers using it.

2
  • Please have a look at the answers to this question.
    – Tanvir
    Jun 2 '20 at 16:09
  • Thank you. It's not exactly what I want : I still want chapters to be numbered in the TOC. Jun 2 '20 at 16:17
0

You only need to redefine \thesection and \p@section.

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

\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand{\thesection}{\arabic{section}}
\makeatletter
\renewcommand{\p@section}{\thechapter.} 
\makeatother


\begin{document}

% Here, we should see 1. First section......
\tableofcontents

\chapter{First chapter}

\section{First section}\label{sec:first-section}

First content.

\section{Second section}

Other content.

\chapter{Second chapter}

\section{section in second chapter}

Last content, referring to section~\ref{sec:first-section}. % Displayed as "I.1"

\end{document}
6
  • What is \p@section ? Is it described in the Latex macros? Jun 2 '20 at 16:29
  • you ca find it in source2e
    – touhami
    Jun 2 '20 at 16:34
  • Incredible, here is a latex problem solved in 3 simple lines... and this has the added benefit that titlesec and titletoc packages are not needed anymore. Jun 2 '20 at 16:34
  • I am being futile, but now from within a chapter, is there a way to refer to same-chapter sections without the \p@section part?... I am using the cleverref package. For example by using a new macro \localcref? Jun 3 '20 at 20:51
  • 1
    @PlasmaBinturong here you are tex.stackexchange.com/questions/262652/…
    – touhami
    Jun 4 '20 at 21:22

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.