5

In my writing, I do a lot of examples, and these examples fall into different sections. I tried to make them numbered neatly with writing the example number and section number. I have done it in that way:

\usepackage{amsthm}
\theoremstyle{definition}
\newtheorem{exmp}{Ex}[section]

and inside one of the sections I wrote the following:

\begin{exmp}
This is my first example
\end{exmp}

\begin{exmp}
This is my second example
\end{exmp}

The output was:

enter image description here

I need to make the numbering of these examples written as:

(5.1.1) This is my first example \label{1st}

(5.1.2) This is my second example \label{2nd}

(5.1.2-a) This is a sub of my second example \label{sub-2nd}

and not in bold

lol745
  • 173

2 Answers2

1

You can do that with thmtools:

\documentclass[12pt, a4paper, french]{book}
%***************************************packages***************************************
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern} %
\usepackage{stmaryrd}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{tikz,tkz-tab}
\usepackage{textgreek}
\usepackage{babel}
%***************************************entête***************************************
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\renewcommand\headrulewidth{0pt}
\renewcommand{\sectionmark}[1]{\markright{\thesection{} \ #1}}
\fancyhead[RO]{\textsl{\rightmark}}
\fancyhead[LE]{\textsl{\leftmark}}
\fancyhead[LO]{\textsl{\thepage}}
\fancyhead[RE]{\thepage}

\usepackage{xpatch}
\makeatletter
\xpatchcmd{\tableofcontents}{%
\@mkboth{%
           \MakeUppercase\contentsname}{\MakeUppercase\contentsname}}{%
\@mkboth{%
 \contentsname}{\contentsname}}{}{}%
\makeatother
\begin{document}
%***************************************couverture***************************************
\begin{titlepage}
\Huge\bfseries \centering
Mon joli titre
\end{titlepage}
%*********************

\chapter{Un premier chapitre}
\section{Première section}
\section{Deuxième section}
\section{Troisième section}
\section{Quatrième section}
\section{Cinquième section}

\chapter{Un autre chapitre}
\section{Première section}
\section{Deuxième section}
\section{Troisième section}
\section{Quatrième section}
\section{Cinquième section}

\chapter{Encore un autre}
\section{Première section}
\section{Deuxième section}
\section{Troisième section}
\section{Quatrième section}
\section{Cinquième section}

\chapter{Un autre encore}
\section{Première section}
\section{Deuxième section}
\section{Troisième section}
\section{Quatrième section}
\section{Cinquième section}



\chapter{Un dernier chapitre}
\section{Première section}
\section{Deuxième section}
\section{Troisième section}
\section{Quatrième section}
\section{Cinquième section}


%%*****************table des matières***************************************
\tableofcontents

\end{document}*

enter image description here

Bernard
  • 271,350
1

Since it appears from the comments that you are using this for numbering linguistic examples, it would probably make more sense to use one of the packages for that, since they also come with glossing macros. Here's an example using gb4e:

\documentclass{book}
\usepackage{chngcntr}
\usepackage{gb4e}

\counterwithin{xnumi}{section} % the chngcntr way (preferred)
\exewidth{(5.1.234)} % leave enough room for the example number
\begin{document}
\setcounter{chapter}{4}
\chapter{}
\section{A section}

\begin{exe}
\ex First example
\label{ex:first}
\end{exe}
\begin{exe}
\ex Second example
\label{ex:second}
\end{exe}

This is a reference to (\ref{ex:first}).
\end{document}

output of code

Alan Munn
  • 218,180