# Part numbering with suffixes: I, II, IIIa, IIIb, IV,

I would like to have my parts numbered like this:

I, II, IIIa, IIIb, ... , IV, ...

I have written some code which works fine. But when using hyperref, I get this warning: destination with the same identifier (name{part.1}) has been already used, duplicate ignored, because I reset the counter to zero for the sub-numbering.

## Question

Is there any way to achieve the same result, but without reseting the part counter (and without producing hyperref-warnings)?

## Code

\documentclass{article}
\usepackage{hyperref}

\begin{document}
\tableofcontents
\pagebreak

\part{First}
\part{Second}

% change part numbering to ROMAN alph
\newcommand{\thelastpart}{\arabic{part}}%store old number
\edef\thelastpartexp{\thelastpart}
\edef\themainpart{\thepart}
\setcounter{part}{0}%set subcounter
\renewcommand{\thepart}{\themainpart\alph{part}}

\part{Third a}
\part{Third b}

% reset part numbering
\setcounter{part}{\thelastpartexp}%restore counter
\renewcommand{\thepart}{\Roman{part}}

\part{Fourth}

\end{document}

-
if you can, I would look at writing something like a \subpart command to do this for you, and potentially not including it in the toc (or is the TOC a necessary feature?) – Sean Allred Apr 17 '13 at 13:30
It has to be in the TOC, as the part is just "splitted into two" – ralfix Apr 17 '13 at 13:33

To make hyperref happy with your own solution it is enough to redefine \theHpart so that it gives unique values, e.g.:

\documentclass{article}
\usepackage{hyperref}

\begin{document}
\tableofcontents
\pagebreak

\part{First}
\part{Second}

% change part numbering to ROMAN alph
\newcommand{\thelastpart}{\arabic{part}}%store old number
\edef\thelastpartexp{\thelastpart}
\edef\themainpart{\thepart}
\setcounter{part}{0}%set subcounter
\renewcommand{\thepart}{\themainpart\alph{part}}
\renewcommand{\theHpart}{\themainpart\alph{part}}%<--------------

\part{Third a}
\part{Third b}

% reset part numbering
\setcounter{part}{\thelastpartexp}%restore counter
\renewcommand{\thepart}{\Roman{part}}
\renewcommand{\theHpart}{\Roman{part}} %<--(probably not really needed)

\part{Fourth}

\end{document}

-
Wow. Very simple and impressive. Thank you, learned a lot :) – ralfix Apr 20 '13 at 11:28

Here's a solution inspired by subequation. You use the command \Part that takes an optional argument in which you can specify the subpart option for those parts you want to share the main number. You can also specify toctitle=... for a different title that should go in the TOC.

\documentclass{article}
\usepackage{hyperref}

\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\Part}{ O{} m }
{
\ralfix_part:nn { #1 } { #2 }
}
\keys_define:nn { ralfix/part }
{
toctitle .tl_set:N = \l_ralfix_toctitle_tl,
subpart .bool_set:N = \l_ralfix_subpart_bool,
subpart .default:n = { true },
}
\cs_new_protected:Npn \ralfix_part:nn #1 #2
{
\keys_set:nn { ralfix/part }
{
subpart=false,
toctitle=#2,
#1
}
\bool_if:NTF \l_ralfix_subpart_bool
{
\int_compare:nT { \value{subpart} = 0 }
{
\stepcounter{part}
\cs_gset:Npx \thepart { \thepart \exp_not:N \alph{subpart} }
\cs_gset_eq:cc { c@part } { c@subpart }
}
}
{
\cs_gset_eq:cN { c@part } \ralfix_part_counter:
\cs_gset_eq:NN \thepart \ralfix_part_thepart:
\int_compare:nT { \value{subpart}=1 }
{
\use:c { @latex@warning@no@line }
\int_to_Roman:n {\value{part}-1},~%
check~your~input }
}
\setcounter{subpart}{0}
}
\stepcounter{Hpart} % keep hyperref happy
\part[\l_ralfix_toctitle_tl]{#2}
}

\cs_set_eq:Nc \ralfix_part_counter: { c@part }
\cs_set_eq:NN \ralfix_part_thepart: \thepart
\ExplSyntaxOff
\newcounter{Hpart}
\newcounter{subpart}

\begin{document}
\tableofcontents
%\pagebreak

\Part{First}
\Part{Second}

\Part[subpart]{Third a}
\Part[subpart,toctitle=Third toc b]{Third b}

\Part{Fourth}

\end{document}


Note: added a warning if there's a single subpart.

-
This is really nice, but "heavy"... Thank you for providing (another) xparse-solution, I learn a lot from your answers. – ralfix Apr 20 '13 at 11:30
@ralfix If you look closely, it's not very different in implementation from Ulrike's, but it spares you from complicated code in the body of the document. – egreg Apr 20 '13 at 12:12

I would create a whole other sectioning command, like so:

\documentclass{article}
\usepackage{mwe}
\usepackage{hyperref}

\newcommand{\formatsubparttext}{\Large\bfseries}

\newcounter{subpart}[part]
\newcommand{\subpart}[1]{%
\vspace*{1em}\noindent %
\par\vspace*{1em}
{\formatsubparttext #1}%
\par\vspace*{2em}\noindent%
}

\begin{document}
\tableofcontents
\part{Part One}
\subpart{Something}
\lipsum[1]
\subpart{Something Else}
\lipsum[2]
\part{Part Two}
\lipsum[3]
\end{document}


Output:

-
Real quick: Just in case Part II (and any later parts) also feature subparts, you should modify the \part command so that the subpart counter is reset to 0 automatically. – Mico Apr 17 '13 at 15:06
Edited, thanks for that. (Although there is a smarter way that I can't get working.) – Sean Allred Apr 17 '13 at 16:25
Wouldn't \newcounter{subpart}[part] be easier to let the subpart counter reset at new parts? – clemens Apr 17 '13 at 17:06
I need the splitted part to look exactly like the non-splitted ones, so this is not the solution I am looking for... Thank you! – ralfix Apr 20 '13 at 11:29
@ralfix Fair enough. – Sean Allred Apr 20 '13 at 11:49