2

How do I put a prime superscript on ii in (ii)? MWE:

\documentclass{article}
\usepackage{enumitem}
\begin{document}
\begin{enumerate}[label=(\roman*)]
\item\label{A} First
\item\label{B} Second
\item\label{C} Want to have (ii') here.
\item\label{D} Fourth
\end{enumerate}
Let's reference them: \ref{A}, \ref{B}, \ref{C} (want to have (ii') also here), and \ref{D}.
\end{document}

As opposed to that, I want to have

(i) First

(ii) Second

(ii') Another version of (ii).

(iii) Fourth

Let's reference them: (i), (ii), (ii'), (iii).

How to do that in latex without introducing global changes to standard macros? We are still allowed to introduce our own, fresh macros and local changes to standard macros. Moreover, I'd still like to reference all the items with \ref{A}, \ref{B}, \ref{C}, \ref{D}, not with (\ref{A}), (\ref{B}), (\ref{C}), (\ref{D}).

The suggestion Referencing a custom labeled item in enumitem inline list doesn't put a prime into the parentheses (at least, I don't know how to do it). Dropping the parentheses globally as in How do I put subscripts on referenced items with enumitem? would require me to introduce parentheses manually into references to many list items in all the remaining 100+ pages of a book; it's not something I'd like to have. (The comments to the accepted answer there are confusing, btw.) The only portion of latex code I would like to change is really the list in question and its surroundings, and, perhaps, the preamble.

Addendum: when using cleveref in addition, see the question for enumitem and cleveref.

0

2 Answers 2

3

The main question is how to print the prime.

\documentclass{article}
\usepackage{textcomp}
\usepackage{enumitem}
\makeatletter
\newcommand\myprimeitem{%
 \item[(\roman{enumi}\textquotesingle)]\def\@currentlabel{(\roman{enumi}\textquotesingle)}}
\makeatother
\begin{document}
\begin{enumerate}[label=(\roman*)]
\item\label{A} First
\item\label{B} Second
\myprimeitem\label{C} Second again
\item\label{D} Fourth
\end{enumerate}
Let's reference them: \ref{A}, \ref{B}, \ref{C}, \ref{D}
\end{document}

enter image description here

1
  • textcomp is a core package to load the TS1 encoding. There is no problem to load it. Commented Jul 23, 2016 at 20:00
2

It is easier to NOT use the enumitem package for this. The reason for this is that \refstepcounter uses \theenumi but \item (as defined by the package) does not. (Note, this only works for the first level. The counter names are enumi, enumii, enumiii, etc.)

\documentclass{article}
%\usepackage{enumitem}

\newcommand{\itemprime}[1]% #1 = contents (inside group)
{\bgroup% make changes local
  \renewcommand{\theenumi}{(\roman{enumi}')}%
  \addtocounter{enumi}{-1}%
  \item#1
\egroup}

\begin{document}
\begin{enumerate}\renewcommand{\theenumi}{(\roman{enumi})}
\item\label{A} First
\item\label{B} Second
\itemprime{\label{C} Want to have (ii') here.}
\item\label{D} Fourth
\end{enumerate}
Let's reference them: \ref{A}, \ref{B}, \ref{C} (want to have (ii') also here), and \ref{D}.
\end{document}

demo

0

You must log in to answer this question.