This question is tied to my other question about French section numbering using bis, ter, etc. The previous question gave me a method to number the different sections with the latin bis, ter, and others in sequential order.
Now I am trying to cross-reference these sections but the cross reference numbering is not working out correctly. Please consider the MWE below, which is slightly tweaked from the answer to the aforementioned question.
\documentclass{book}
\usepackage{xparse}
\usepackage{enumitem}
\usepackage[explicit]{titlesec}
\usepackage{lipsum}
\usepackage{calc}
\usepackage{totcount}
\usepackage{hyperref}
\ExplSyntaxOn
\seq_new:N \bislist
\seq_set_split:Nnn \bislist {;} {bis;ter;quater;quinquies;sexies;septies;octies;novies;decies}
\NewDocumentCommand {\bisprint} {m}
{
\seq_item:Nn \bislist {#1}
}
\ExplSyntaxOff
\newtotcounter{bismax}
\newcounter{bis}
\stepcounter{bis}
\setcounter{bismax}{1}
\newcommand{\bisadd}{\stepcounter{bis} \setcounter{bismax}{\minof{4}{\maxof{\thebismax}{\thebis-1}}}}
\AtBeginDocument{\newlength{\bislength}
\settowidth{\bislength}{\textit{\bisprint{\totvalue{bismax}}}}
\addtolength{\bislength}{1.5em}}
\titleformat{\section}[block]{\normalfont\large\normalfont\filcenter}{\thesection. --- #1}{0.5em}{}[\setcounter{bis}{1}]
\renewcommand\thesection{\arabic{section}}
\titleformat{name=\section,numberless}[block]{\normalfont\large\normalfont\filcenter}{\arabic{section} \textit{\bisprint{\arabic{bis}}}. --- #1}{0.5em}{}[ \addcontentsline{toc}{section}{\protect\numberline{\arabic{section} \textit{\bisprint{\arabic{bis}}}}#1} \bisadd{}]
\makeatletter
\renewcommand*\l@section{\@dottedtocline{1}{1.5em}{\bislength}}
\makeatother
\begin{document}
\tableofcontents
\section{First section header}\label{Sec1}
\lipsum[5]
\section*{Second section header}\label{Sec1bis}
\lipsum[6]
\section*{Third section header}\label{Sec1ter}
\lipsum[7]
Let's reference Section \ref{Sec1bis} and \ref{Sec1ter} here. This should have said "Section 1 \textit{bis} and Section 1 \textit{ter}." You will see that the cross-references do not work out correctly.
\end{document}
This produces the following output:
As you can see, the last paragraph attempts to cross-reference Sections 1 bis and 1 ter, but the Latin ordinals aren't properly shown. I assume this has something to do with the \section* command, but I really don't know for sure.




\usepackage[explicit]{titlesec}to work. Putting the[explicit]flag in makes the section headers in the body of the document disappear with your syntax. How can I avoid this? – grfrazee Sep 17 '15 at 20:36explicitoption is almost never needed. If you must use it, put#1in the now empty pair of braces at the end of the\titleformatcommand. – egreg Sep 17 '15 at 20:40\section*{}command, which was something that didn't quite sit well with me on my MWE. – grfrazee Sep 17 '15 at 20:43