How to interrupt/resume a list in LaTeX? - latex

I want to produce output something like this:
1. List item
2. Another list item
Paragraph of comments on list items 1 and 2.
3. Further item
4. Final item
I'm sure I've seen a nice way to interrupt and resume lists in this way (without explicitly setting some counter), but I can't reproduce it.

I like enumitem for this sort of thing:
\documentclass{article}
\usepackage{enumitem}
\begin{document}
\begin{enumerate}
\item List item
\item Another list item
\end{enumerate}
Paragraph of comments on list items 1 and 2.
\begin{enumerate}[resume]
\item Further item
\item Final item
\end{enumerate}
\end{document}

The TeX FAQ lists several ways of doing this. Read here for full details.
I've successfully used the mdwlist package (which is part of mdwtools) in my own documents. For example:
\documentclass{article}
\usepackage{mdwlist}
\begin{document}
\begin{enumerate}
\item List item
\item Another list item
\suspend{enumerate}
Paragraph of comments on list items 1 and 2.
\resume{enumerate}
\item Further item
\item Final item
\end{enumerate}
\end{document}
Thanks to Dervin Thunk for providing the FAQ link.

\documentclass{article}
\begin{document}
\begin{enumerate}
\item first;
\item second;
\end{enumerate}
This is a paragraph.
\begin{enumerate}
\setcounter{enumi}{2}
\item third;
\item and so on...
\end{enumerate}
\end{document}
edit: as pointed out by Dervin Thunk, I hardcoded 2 here.
so, here's a solution that seems to work:
\documentclass{article}
\newcounter{tempcounter}
\begin{document}
\begin{enumerate}
\item first;
\item second;
\setcounter{tempcounter}{\value{enumi}}
\end{enumerate}
This is a paragraph.
\begin{enumerate}
\setcounter{enumi}{\value{tempcounter}}
\item third;
\item and so on...
\end{enumerate}
\end{document}

You can use newcounter and usecounter to get around this -- here's an example.

Related

How can one start an \item with a math align environment?

In latex, I need to start an item in an enumerate list with an align* environment, but this environment starts with a new line, leaving an ugly empty space.
What I'm trying to achieve:
e^{ix}=cos x+i sin x
e^{i\pi} = -1
e^{i\pi}+1=0
What I'm trying:
\begin{enumerate}
\item \begin{align*}
e^{ix}&=\cos x+i\sin x\\
e^{i\pi}&=-1\\
e^{i\pi}+1&=0
\end{align*}
\end{enumerate}
Is there some other environment for this?
(I know that it is not recommended to start an item with a displayed math formula, but in this case I need to.)
As a workaround:
\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{enumerate}
\item \hfill$\begin{aligned}[t]
e^{ix}&=\cos x+i\sin x\\
e^{i\pi}&=-1\\
e^{i\pi}+1&=0
\end{aligned}$\hfill\mbox{}
\end{enumerate}
\end{document}
A hack similar to the one in the accepted answer: the environment matrix needs no package to work and has no visible delimiters:
\documentclass{article}
\begin{document}
\begin{enumerate}
\item $\begin{matrix}
e^{ix}&=\cos x+i\sin x\\
e^{i\pi}&=-1\\
e^{i\pi}+1&=0
\end{matrix}$
\end{enumerate}
\end{document}
The output seems to me similar to the one you wanted to achieve:

How do I left justify text between enumerates in LaTex?

\begin{enumerate}
\def\labelenumi{\Alph{enumi}.}
\item
The \textbf{Definition} of ``Period of Restoration'' is replaced by
the following:
\begin{enumerate}
\def\labelenumii{\arabic{enumii}.}
\setcounter{enumii}{2}
\item
``Period of Restoration'' means the period of time that:
\begin{enumerate}
\def\labelenumiii{\alph{enumiii}.}
\item
Begins:
\begin{enumerate}
\def\labelenumiv{(\arabic{enumiv})}
\item
72 hours after the time of direct physical loss or damage for
Business Income coverage; or
\item
Immediately after the time of direct physical loss or damage for
Extra Expense coverage;
\end{enumerate}
caused by or resulting from any Covered Cause of Loss at the
described premises; and
\item
Ends on the earlier of:
\begin{enumerate}
\def\labelenumiv{(\arabic{enumiv})}
\item
The day before the opening of the next school term following the
date when, with reasonable speed and similar quality, the
property at the described premises should be repaired, rebuilt
or replaced; or
\item
The date when the school term is resumed at a new permanent
location.
\end{enumerate}
"Period of Restoration" does not include any increased period required due to the enforcement of any ordinance or law that:
I need the last line to line up under b. and it is lining up under (2)
I am getting this:
I believe you need two \end{enumerate} 's after the "The date ... permanent location." line.
\documentclass[]{article}
\begin{document}
\begin{enumerate}
\def\labelenumi{\Alph{enumi}.}
\item
The \textbf{Definition} of ``Period of Restoration'' is replaced by
the following:
\begin{enumerate}
\def\labelenumii{\arabic{enumii}.}
\setcounter{enumii}{2}
\item
``Period of Restoration'' means the period of time that:
\begin{enumerate}
\def\labelenumiii{\alph{enumiii}.}
\item
Begins:
\begin{enumerate}
\def\labelenumiv{(\arabic{enumiv})}
\item
72 hours after the time of direct physical loss or damage for
Business Income coverage; or
\item
Immediately after the time of direct physical loss or damage for
Extra Expense coverage;
\end{enumerate}
caused by or resulting from any Covered Cause of Loss at the
described premises; and
\item
Ends on the earlier of:
\begin{enumerate}
\def\labelenumiv{(\arabic{enumiv})}
\item
The day before the opening of the next school term following the
date when, with reasonable speed and similar quality, the
property at the described premises should be repaired, rebuilt
or replaced; or
\item
The date when the school term is resumed at a new permanent
location.
\end{enumerate}
\end{enumerate}
``Period of Restoration" does not include any increased period required due to the enforcement of any ordinance or law that:
\end{enumerate}
\end{enumerate}
\end{document}
The first \end{enumerate} got you from being aligned with the T in "The date when the school term...." to being aligned with the (2). You need one more to get you out to align with the b.
If you need to pick up the list from where you left off (3c, 3d, etc.) further down, you can do it using \setcounter so that it doesn't start over again at a; here's an example:
\documentclass[]{article}
\begin{document}
\begin{enumerate}
\item text
\item text
\item text
\end{enumerate}
Text Text Text
\begin{enumerate}
\setcounter{enumi}{3}
\item pickup where left off
\item text
\end{enumerate}
\end{document}
I wrote a small macro called unclip.
Used with all lowercase, it will end a list, write the given contents, and resume the list.
Used with uppercase U, it will gather the enumeration-number before writing the contents and restore it when resuming the list.
\newcommand{\unclip}[2][enumerate]{\end{#1}#2\begin{#1}}%
\makeatletter
\newcommand{\Unclip}[2][enumerate]{%
\#ifundefined{c#saveenum#\romannumeral\#enumdepth}% create temporary counter
{\newcounter{saveenum#\romannumeral\#enumdepth}}{}%
\setcounter{saveenum#\romannumeral\#enumdepth}% store item number
{\value{enum\romannumeral\#enumdepth}}%
\end{#1}#2\begin{#1}% end list, write content, resume
\setcounter{enum\romannumeral\#enumdepth}% restore item number
{\value{saveenum#\romannumeral\#enumdepth}}}%
\makeatother
You can stack it for multiple levels. Be aware that it may give an error if you stack it, unless you use an \item[] after each inner call. It will still compile though.
Extensive example:
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\newcommand{\unclip}[2][enumerate]{\end{#1}#2\begin{#1}}%
\makeatletter
\newcommand{\Unclip}[2][enumerate]{%
\#ifundefined{c#saveenum#\romannumeral\#enumdepth}% create temporary counter
{\newcounter{saveenum#\romannumeral\#enumdepth}}{}%
\setcounter{saveenum#\romannumeral\#enumdepth}% store item number
{\value{enum\romannumeral\#enumdepth}}%
\end{#1}#2\begin{#1}% end list, write content, resume
\setcounter{enum\romannumeral\#enumdepth}% restore item number
{\value{saveenum#\romannumeral\#enumdepth}}}%
\makeatother
\begin{document}
\begin{itemize}
\item TestItem A
\begin{description}
\item[preparation] No Item-number yet, so only smallercase unclip
\item[test] and action:
\unclip[description]{This should be below \textit{TestItem A}}
\item[Test] And now inside a enumeration:
\begin{enumerate}
\item One
\item Two
\Unclip{This should be under \textit{Test}}
\item Three
\Unclip{But now we are stacking, by calling
\textbackslash Unclip\{\textbackslash unclip[description]\{text\}\}
\unclip[description]{so this should be under \textit{TestItem A}
\\Be aware it will raise an error, eventhough it works fine.
\unclip[itemize]{And while you can have text in front of an inner unclip,
doing it the other way round would seriously fuck up your layout.}}}
\item Four
\begin{enumerate}
\item Unus
\item Duo
\item Tres
\Unclip{Yes, you can \Unclip{unclip multiple
\unclip[description]{levels just fine.
\unclip[itemize]{Still works. :-)}}}}
\item Quattuor
\Unclip{\Unclip{\unclip[description]{\unclip[itemize]{By the way:}
\item[]You can get rid of the errors,}\item[and] stack it back in}
\item[] by using \textbackslash item[] after the inner unclips}
\item Quinque
\item \dots
\end{enumerate}
\end{enumerate}
\end{description}
\item TestItem B
\end{itemize}
\end{document}
I hope it helps.
Cheers.
You have to use \noindent
You just have an indent ;)

How to make Latex display two items per row?

I am using this resume template to create my resume: https://github.com/posquit0/Awesome-CV.
I am completely new to latex. Currently, when I use cvitems:
%Define an environment for cvitems(for cventry)
\newenvironment{cvitems}{
\vspace{-4mm}
\begin{justify}
\begin{itemize}[leftmargin=2ex, nosep, noitemsep]
\setlength{\parskip}{0pt}
\renewcommand{\labelitemi}{\bullet}
}{
\end{itemize}
\end{justify}
\vspace{-2mm}
}
All the items are listed as follow:
item A
item B
What modifications to the above code can I make so that the list can look like this (item A and item B are on the same row)?
item A * item B
Here is how I use cvitems in the tex file:
{\begin{cvitems}
\item {item A}
\item {item B}
\end{cvitems}}
I would define a special command for two-item items as follows
\newcommand\twoitems[2]{%
\item#1%
\hspace{10pt}%
\labelitemi
\hspace{\labelsep}#2
}
Notice I used 10pt as spacing between items, you could use a different one.
Here is an MWE that applies the idea. In this example, I keep the cvitmems as in your MWE, though in truth it is really not doing anything, that is, you could as well use the standard itemize environment.
\documentclass{article}
\begin{document}
\newcommand\twoitems[2]{%
\item#1%
\hspace{10pt}%
\labelitemi
\hspace{\labelsep}#2
}
\newenvironment{cvitems}%
{
\begin{itemize}
}%
{
\end{itemize}
}
\begin{cvitems}
\item A
\item B
\twoitems{A}{B}
\end{cvitems}
\end{document}
Here's the output: https://i.stack.imgur.com/BZvt0.png

org-mode: framebreak does not work with label option in exported beamer

I'm using org-mode to generate beamer presentations. I have
(setq org-beamer-frame-default-options "allowframebreaks")
so my exported latex is like this:
\begin{frame}[allowframebreaks,label=sec-1-1-1]{Framebreak test}
First List
\begin{itemize}
\item TEST
\item TEST
\item test
\item test
\item test
\item test
\item test
\item test
\item test
\end{itemize}
Second List
\begin{itemize}
\item TEST
\item TEST
\item test
\item test
\item test
\item test
\item test
\item test
\item test
\end{itemize}
\end{frame}
However when I compile this with pdflatex, the framebreak does not work. (It just generate one slide for this page, remaining stuff truncated).
But if I manually remove label=sec-1-1-1 so I only have \begin{frame}[allowframebreaks]{Framebreak test}, framebreak works well. Is this a bug or am I doing something wrong?
IIRC, this is related to bug #265 in Beamer itself. Until solved, you should try:
(setq org-beamer-frame-default-options "allowframebreaks,label=")
Okay. It seems it is fixed in the newer version of org-mode - search for Provide an automatic label for the frame in the source code. Apparently it hasn't been yet fixed in Org mode version 8.2.10. I guess I have to use the developmental version for now.
EDITED: with Org mode 8.3beta, if a heading has :BEAMER_OPT: allowframebreaks property, then ox-beamer will not generate the automatic label.

Changing the numberings of nested lists in an Enumerate environment, in LaTeX

I want to produce the following in LaTeX:
1. Item
2. Item
3a. Item
3b. Item
4. Item
5. Item
Basically I have already tried using nested enumerate environments, but I have a problem with implementing the different numberings.
How can I do the above in LaTeX?
The purpose of the {enumerate} environment is to number things algorithmically. If you really want the numbers to appear as shown in your question, I can't identify what algorithm you want to be used. For the example you show, I think the easiest method is just to program the labels yourself instead of trying to program LaTeX to do it. I would just do it this way:
\begin{itemize}
\item[1.] Item
\begin{itemize}
\item[2. ] Item
\item[3a. ] Item
\item[3b. ] Item
\item[4. ] Item
\end{itemize}
\item [5. ] Item
\end{itemize}
With LaTeX, the quickest path to a solution often involves brute force :-)
Quick and dirty:
\documentclass{article}
\begin{document}
\renewcommand{\labelenumii}{\addtocounter{enumi}{1}\arabic{enumi}}
%% Second list uses first counter
\def\startenumtuple{\setcounter{enumii}{1}\addtocounter{enumi}{1}
\renewcommand{\labelenumii}{\arabic{enumi}.\alph{enumii}}}
\def\endenumtuple{
\renewcommand{\labelenumii}{\addtocounter{enumi}{1}\arabic{enumi}}}
\noindent Here's my list:
\begin{enumerate}
\item Item
\begin{enumerate}
\item Item
\startenumtuple
\item Item
\item Item
\endenumtuple
\item Item
\item Item
\end{enumerate}
\item Item
\end{enumerate}
\end{document}
(Mica's version was used in the first iteration of this code)
The right way involves defining environments based on enumerate that do the right thing with the counters: the above code would need tweaking to get it to work right if you wanted to change the nesting of the list environments.
\renewcommand{\labelenumi}{\Roman{enumi}.}
\renewcommand{\labelenumii}{\Roman{enumi}. \alph{enumii}}
\noindent Here's my list:
\begin{enumerate}
\item Item 1.
\begin{enumerate}
\item List 2, Item 1
\item List 2, Item 2
\end{enumerate}
\item Item 2.
\item Item 3.
\end{enumerate}
Then change the \Roman in the renewcommand to whatever you want it to be: \alph or \arabic

Resources