0

I am trying to format the chapter, section and subsection but I have not been able to. I have included an image as a reference of what I want to do. Here are some specifics:

  • LaTeX, by default, puts the chapter title in the header. I don't want that.
  • Regarding the subsection: I wish not to list the number, but I would love to leave a space (check the image)
  • And finally I want to put the page enumeration in the upper right corner (they said to use fancyhdr but I don't know where to start).

reference image

\documentclass[12pt]{book}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[left=3cm,top=2.5cm,bottom=2.5cm, right=2.5cm,showframe=false]{geometry}

\usepackage{titlesec}

% ------- format chapter - section and subsection

\renewcommand{\thechapter}{\Roman{chapter}} \renewcommand{\thesection}{\arabic{chapter}.\arabic{section}} \renewcommand{\thesubsection}{\thesection. \arabic{subsection}}

\titleformat{\chapter}[display] {\normalfont\LARGE\bfseries\centering } {\vspace{\stretch{1}} \chaptertitlename\ \thechapter}{20pt}{\Huge} [\vspace{\stretch{1}}\clearpage] \titlespacing*{\chapter}{0pt}{0pt}{0pt}

\titleformat{name=\chapter,numberless}[display] {\normalfont\Large\bfseries} {} {0pt} {\Huge} [] % code reference --- https://tex.stackexchange.com/a/13498

\begin{document}

\chapter{An Title another pg}

\section{Introduction} \subsection{International}

\section{Methods} \subsection{Materiales}

\end{document}

I have marked in red what I would like to change

enter image description here

Werner
  • 603,163
royer
  • 361
  • 1
  • 14
  • It's usually best to define the hierarchical section numbering scheme hierarchically. So, \renewcommand{\thesection}{\thechapter.\arabic{section}}, otherwise you're changing the representation of the chapter counter from \Roman (in the chapter title) to \arabic (in the section title). Is this your main issue? – Werner Aug 10 '21 at 23:38
  • no, the problem is that when doing that it combines the roman with the arabic, my objective is only to format the subsection and that the chapter is not shown in the header. Look at the picture – royer Aug 10 '21 at 23:45
  • None of that is in the description of your problem. Please update the question and clarify exactly what you need. – Werner Aug 10 '21 at 23:46
  • @Werner Thank you very much for your attention, I have changed it, I hope this time it is understandable – royer Aug 10 '21 at 23:52

1 Answers1

0

I have added the fancyhdr definitions for your page layout.

And for the subsection I have added a \titleformat that eliminates the subsection number. Please note that the subsection number will appear in the table of contents. If you want to eliminate that, then use the second definition of \thesubsection. The side effect will be that you can't refer to subsections, but that would be hard anyway with no subsection numbers in the headings.

\documentclass[12pt]{book}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[left=3cm,top=2.5cm,bottom=2.5cm, right=2.5cm,showframe=false]{geometry}
\usepackage{fancyhdr}
\fancyhf{}
\fancyhead[R]{\thepage}
\renewcommand{\headrulewidth}{0pt}
\pagestyle{fancy}
\fancypagestyle{plain}{\fancyhf{}}

\usepackage{titlesec}

% ------- format chapter - section and subsection

\renewcommand{\thechapter}{\Roman{chapter}} \renewcommand{\thesection}{\arabic{chapter}.\arabic{section}} \renewcommand{\thesubsection}{\thesection.\arabic{subsection}} %\renewcommand{\thesubsection}{}

\titleformat{\chapter}[display] {\normalfont\LARGE\bfseries\centering } {\vspace{\stretch{1}} \chaptertitlename\ \thechapter}{20pt}{\Huge} [\vspace{\stretch{1}}\clearpage] \titlespacing*{\chapter}{0pt}{0pt}{0pt}

\titleformat{name=\chapter,numberless}[display] {\normalfont\Large\bfseries} {} {0pt} {\Huge} [] % code reference --- https://tex.stackexchange.com/a/13498 \titleformat{\subsection}{\large\bfseries}{}{4em}{}

\begin{document} \tableofcontents \chapter{An Title another pg}

\section{Introduction} \subsection{International}

\section{Methods} \subsection{Materiales}

\end{document}

enter image description here