Sign up ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

When I define two new level using titlesec, the reference doesn't work correctly.

This is an example:



% First level
\titleformat{\exemple}[runin]{}{\theexemple}{0em}{Exemple \ }[\quad]


% -------------------------------------------------------------------
% second one

\titleformat{\suiteexemple}[runin]{}{\thesuiteexemple}{0em}{Suite de l'exemple \ }[\quad]

% -------------------------------------------------------------------


\section{one} \label{sec:one}


\exemple{First exemple} 

\exemple{Second example}



Reference to exemple : \ref{ex:one}


The reference is displayed as "1", but it should be "1.1" (the exemple counter is not displayed).

If you comment the code between the % ------ the reference is correctly displayed.

Do you know any workaround on this problem?

share|improve this question
I get "Reference to exemple : 1" (just copied an pasted from the PDF file). – egreg Apr 27 '13 at 15:06
Yep, but it should be "Reference to exemple : 1.1" – Paul Pichaureau Apr 27 '13 at 17:08
Sorry I don't know how to include the result of a compilation. – Paul Pichaureau Apr 27 '13 at 17:08

1 Answer 1

up vote 1 down vote accepted

The problem is in how \titleclass works.

With \titleclass{\exemple}{straight}[\subsection] you're inserting a new numbering level between \subsection and \subsubsection. So \example becomes level 3 and \subsubsection is shifted to level 4.

With the following \titleclass{\subexemple}{straight}[\subsection] you do the same, so \subexemple becomes level 3 and \exemple is shifted to level 5.

Therefore, with the usual value of 3 for secnumdepth, \exemple loses its numbering and the \label{ex:one} command will refer to the last "refstepped" command which happened at \section{one}.

You probably have better to define \suiteexemple in terms of \example* or saying

share|improve this answer
Ok, I get it! I thought \titleclass...[\subsection] define something "at the same level" than \subsection I should define both command in term of \subsection – Paul Pichaureau May 1 '13 at 6:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.