0

I should have searched more for this subject before posting, I'm sure, but I got frustrated with the amount of interesting items of clothing made from latex, so please forgive me if this has already been answered. I'm trying to make a list of examples like:

1.3.i bla bla
1.3.ii and so on
...

I feel I should be able to use \begin{enumerate}[1.3.i], but it comes out as:

i.3.i bla bla
ii.3.ii and so on
...

I suppose it makes sense, since '1' is one of the characters that get interpreted, but isn't there a way to protect the number, when you just want it to be a static part of the label?

1
  • 2
    \documentclass{article} \usepackage{enumerate} \newcommand*{\foo}{1.3} \begin{document} \begin{enumerate}[\foo.i] \item Lorem \item Ipsum \end{enumerate} \end{document} could be a dirty work-around. You may also want to look into the enumitem package. The question is where the "1.3" comes from, maybe that could be automated (for example if it is the subsection number with \thesubsection instead of foo)
    – moewe
    Commented Jul 17, 2018 at 8:09

2 Answers 2

3

You have to hide the fixed part (which contains a 1 that would otherwise be mistaken for a counter denotation):

\documentclass{article}
\usepackage{enumerate}

\begin{document}

\section{Title}
\setcounter{subsection}{2} % faking two subsections

\subsection{Title}

\begin{enumerate}[{1.3}.i]
\item bla bla
\item and so on
\end{enumerate}

\end{document}

enter image description here

It's easier with enumitem that is much recommended over enumerate:

\documentclass{article}
\usepackage{enumitem}

\begin{document}

\section{Title}
\setcounter{subsection}{2} % faking two subsections

\subsection{Title}

\begin{enumerate}[label=1.3.\roman*]
\item bla bla
\item and so on
\end{enumerate}

\end{document}

However, both solutions suffer from the hardcoded 1.3; also, the labels will be poorly aligned. Here's my suggestion:

\documentclass{article}
\usepackage{enumitem}

\begin{document}

\section{Title}
\setcounter{subsection}{2} % faking two subsections

\subsection{Title}\label{ssec:xyz}

\begin{enumerate}[label=\ref{ssec:xyz}.\roman*,align=left]
\item bla bla
\item and so on
\end{enumerate}

\end{document}

Using \label and \ref will ensure the enumeration will have the correct label, independently on possible changes in the material.

enter image description here

1
  • Thanks! So {1.3} works - I should have thought of that. But I will look into to enumitem, it does look better.
    – j4nd3r53n
    Commented Jul 17, 2018 at 9:39
1

You can 'hide' the 1.3 from enumerate's parser by putting it into a macro

\documentclass{article}
\usepackage{enumerate}

\newcommand*{\enumprefix}{1.3}
\begin{document}
\begin{enumerate}[\enumprefix.i]
\item Lorem
\item Ipsum
\end{enumerate}
\end{document}

enter image description here

If the "1.3" is not a random number, but stands in relation with other counters in the document, you may be able to get rid of the \newcommand. If it is the number of the current subsection, you would use

\documentclass{article}
\usepackage{enumerate}

\begin{document}
\section{Foo}
\subsection{Bar}
\begin{enumerate}[\thesubsection.i]
\item Lorem
\item Ipsum
\end{enumerate}
\end{document}

enter image description here

But you could also use the enumitem package, which has a slightly more verbose syntax here, but offers many additional options. Plus, you can hide the more verbose settings in your own macro definitions or apply the globally.

\documentclass{article}
\usepackage{enumitem}

\begin{document}
\section{Foo}
\subsection{Bar}
\begin{enumerate}[label=\thesubsection.\roman*]
\item Lorem
\item Ipsum
\end{enumerate}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .