How do I left justify text between enumerates in LaTex? - 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 ;)

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:

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

How to interrupt/resume a list in 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.

Easiest way to center tables and other elements?

What is the best way to make things center properly? Once I start messing around with tables, things either start shifting left or right, destroying the balance. How can make it so everything is always centered?
Right now this will lead to the table being messed up, and have the right edge go off the screen. What can I do?
Here's most of the code, I cut out a lot of the useless functions, since they are all almost the same. Its for making Use Cases for school, since we got to do about 40 of these for a project.
\documentclass[10pt, a4paper]{article}
\usepackage{booktabs}
\begin{document}
\newcommand{\UCStart}[2]{
\newpage
\subsection[UC.#1]{UC.#1}
\begin{tabular}{|l|m{4in}|c|}
\hline
\textbf{UC.#1}
& \textbf{#2}
& \textbf{Traceability} \\ \hline
}
\newcommand{\UCDesc}[2]{
\textbf{Description}
& #1
& #2 \\ \hline
}
\newcommand{\UCActors}[2]{
\textbf{External Actors}
& #1
& #2 \\ \hline
}
% Snip... 40 odd more functions %
\newcommand{\UCEnd}{
\end{tabular}
}
\begin{table}[!ht]
\setlength{\extrarowheight}{2pt}
% UC 1
\UCStart{01}{Administrator Starts Server}
\UCDesc{This describes the process of the administrator starting the server}{\space}
\UCActors{Administrator}{\space}
\UCRelated{UC.02}{\space}
\UCPre{Server is not running}{\space}
\UCTrigger{Administrator wants to start the server}{\space}
\UCSeq{
\begin{enumerate}
\item Administrator boots up hardware
\item Administrator starts Administrator console
\item Administrator logins into Administrator account with the corresponding password
\item Administrator clicks start
\end{enumerate}
}{\space}
\UCPost{Conditions that must be true, in order for the use case to finish}{\space}
\UCAltSeq{
\textbf{Alternative Use Case 01} \newline
\begin{itemize}
\item UC.01.ALT.01
\item If administrator fails authentication in step 3
\begin{enumerate}
\item Notify administrator of failed authentication
\end{enumerate}
\end{itemize}
}{\space}
\UCNonFunc{ ??? }{\space}
\UCComments{ Comments Go Here }{\space}
\UCEnd
\end{table}
\end{document}
I can't compile your example due to several errors, and I'm not sure what you mean by "the best way to make things center properly". As a kind of crystal ball-type answer, is this what you're looking for?
\documentclass[10pt,a4paper]{article}
\usepackage{array}
\begin{document}
\begin{table}
\centering
\begin{tabular}{
| >{\centering\arraybackslash }p{4cm} |
>{\centering\arraybackslash }p{6cm} |
}
\hline
some centred text in cells & some more centred text in cells \\
\hline
centred text in cells & more centred text in cells \\
\hline
\end{tabular}
\end{table}
\end{document}
It is difficult to see what the problem is when we can't compile your example.
Looking through the code you provided, a table may not actually be appropriate in this situation. Instead, you might try something like the following:
\documentclass[10pt,a4paper]{article}
\begin{document}
\subsection{Administrator Starts Server}
\paragraph{Description:} This describes the process of the adminsitrator starting the server.
\paragraph{Actors:} Administrator
\paragraph{Preconditions:} Server is not running.
\paragraph{Sequence:}
\begin{enumerate}
\item Administrator boots up hardware
\item Administrator starts Administrator console
\item Administrator logins into Administrator account with the corresponding password
\item Administrator clicks start
\end{enumerate}
\end{document}
In the example you provided, I don't see that you ever put any text in the "Traceability" column. To mimic this column, you could either use \marginpar{my text} to put text in the margin, or you could use blahblah\hfill{}my text to right-align text on the same line as "blahblah". If you want the traceability text to be right-aligned and on its own line, use \begin{flushright} my text \end{flushright}.
If this doesn't help solve your problem, please provide us with a minimal example that compiles and demonstrates the problem.

Resources