How to align an enumerated list in latex? - latex

Suppose I want to center align the enumerated list. I did this:
\begin{center}
\begin{enumerate}[label=(\Roman*)]
\item Equation 1
\item Equation 2
\item Equation 3
\item Equation 4
\end{enumerate}
\end{center}
This is not working nicely. I have also tried without 'enumerate' and just 'center' and labeling manually. It does work but the alignment is not looking perfect.
Also instead for center we can also do:
I. Equation 1 \quad II. Equation 2
III. Equation 3 \quad IV.Equation 4

You cannot center an item list like that. Enumerate is a formatting environment that will supersedes the center environment.
What can be done is to put the enumerate list in a box (like a minipage), and to center this box.
Standard minipage requires a width, but there is a package (varwidth) that allows to define minipages with an unknown width (more precisely, you give a width parameter, but if width is smaller than that, the actual with is used).
So here is a solution with varwidth.
\documentclass{article}
\usepackage{enumitem}
\usepackage{varwidth}
\usepackage{tasks}
\begin{document}
\begin{center}
\begin{varwidth}{\textwidth}
\begin{enumerate}[label=(\Roman*)]
\item Equation 1
\item Equation 2
\item Equation 3
\item Equation 4
\end{enumerate}
\end{varwidth}
\end{center}
\end{document}
If you want to have several enumerate items per line, your solution is not very robust, as you must adjust the spacing depending on the item length if you want your items to be aligned.
The 'tabto' package provides a way to do the alignment in a flexible way. But the best solution is to use the 'tasks' package that allows to define columned list. This package is not as smart as others to determine the item width and, if required, this must be given explicitely. The parenthesized parameter is the number of columns. As previously, if you want to center globally the environment, you must use varwidth.
\begin{center}
\begin{varwidth}{\textwidth}
\begin{tasks}[label={(\Roman*)},label-width={1cm}](2)
\task Equation 1
\task Equation 2
\task Equation 3
\task Equation 4
\end{tasks}
\end{varwidth}
\end{center}
For simple lists like yours, a tabular could also be used.

You can just use
\begin{enumerate}[label=(\Roman*)]\centering

Related

sequence in latex not as expected

I just started learning Latex and I have this code in which I first define a figure which is a photo and then I want to have items in my PDF file.
But the output file isn't so and it first shows the items and then the photo! even though I have [!h] statement too.
\documentclass[12pt]{report}
\begin{document}
\begin{figure}[!h]
\centering
\includegraphics[width= 90mm]{./class.jpg}
\caption{pic1}
\end{figure}
\begin{enumerate}
\item first option with number
\item second option with number
\end{enumerate}
\end{document}
What I do is to use the package float and change !h for H
\documentclass[12pt]{report}
\usepackage{float}
\begin{document}
\begin{figure}[H]
\centering
\includegraphics[width= 90mm]{./class.jpg}
\caption{pic1}
\end{figure}
\begin{enumerate}
\item first option with number
\item second option with number
\end{enumerate}
\end{document}
This forces latex to place the image right in the position you put it.
When I compile your code with \usepackage{graphicx}, and using a generic image, I first get the image, then the item list. Usually LaTeX will force the image onto the next empty page, if the image is too large (the width may fit, but possibly the height is off?). Maybe try playing with \includegraphics[scale=0.8].

columns with itemize

I'm trying to make alignment points in a list environment. The following code gives me an error, but it almost compiles to what I want, just missing the bullet points. I must be misunderstanding something about align and/or tabular and how they work with linebreaks. Guidance appreciated!
\documentclass{beamer}
\begin{document}
\begin{frame}
\frametitle{Title}
\begin{itemize}
\begin{tabular}{ll}
\item Topic Apple: &Something to say about it \\
\item Topic Watermelons: &Something different
\end{tabular}
\end{itemize}
\end{frame}
\end{document}
How about this?
\documentclass{beamer}
\begin{document}
\begin{frame}
\frametitle{Title}
\begin{tabular}{p{0.4\textwidth}p{0.5\textwidth}}
\begin{itemize}
\item Topic Apple:
\item Topic Watermelon:
\end{itemize} &
\begin{itemize}
\item[] Something to say about it
\item[] Something to say about it
\end{itemize} \\
\end{tabular}
\end{frame}
\end{document}
Yours will actually work if you change {ll} to {p{width}l} or {p{width}p{width}} but I found that if you don't have itemize in the second column, your text ends up vertically top aligned while the itemized text in the left column is center (or maybe even slightly bottom) aligned vertically so it doesn't look good.
I tried using the array package and m{width} which provides a vertical center alignment but that was still different than whatever itemize is using. I'd say just play with the width argument inside of p{} to get the spacing/width you want. If your right column spills on to another line, you may need a "dummy" item in the right column.
Anyway, based on all the jimmy rigging that might be necessary if things spill onto two lines, I'm assuming my solution is potentially hackish but it looks like it provides what you want for the most part.
the \item[] for the right column is to create the same itemize alignment with no bullet. If you want bullets on the right, just remove the empty square brackets and you'll have them.

Latex: stretchable curly braces outside math

I am producing some latex beamer slides (but I think it is not a beamer specific question per se).
I have the following:
\begin{itemize}
\item Issue1
\item Issue2
\item Issue3
\end{itemize}
Now, I want to have a right curly brace (i.e. '}') behind the items spreading over issue1 and issue2. And of course I want to write something behind that curly brace.
In a perfect world I would write something like:
\begin{itemize}
\left .
\item Issue1
\item Issue2
\right \} One and Two are cool
\item Issue3
\end{itemize}
This does not work because I am not in a math environment and I can not put the whole snippet inside a math environment because itemize would not work in that case.
Is there a clean solution or a hack to produce my desired result?
Regards,
Bastian.
I'd use tikz and make an overlay.
First include the proper packages (you may not need to include tikz since this is a beamer question):
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
Then when you make your list, give names to the places after each item:
\begin{itemize}
\item Issue 1
\tikz[remember picture] \node[coordinate,yshift=0.5em] (n1) {};
\item Issue 2
\tikz[remember picture] \node[coordinate] (n2) {};
\item Issue 3
\end{itemize}
(Note: I shifted the y value up by 1/2 of a line maybe more would be better.)
Because we used remember picture we can refer to these places in an overlay:
\begin{tikzpicture}[overlay,remember picture]
\path (n2) -| node[coordinate] (n3) {} (n1);
\draw[thick,decorate,decoration={brace,amplitude=3pt}]
(n1) -- (n3) node[midway, right=4pt] {One and two are cool};
\end{tikzpicture}
The path is there to deal with items that do not have the same width. This edit comes from ESultanik's answer.
The result is:
Side note: You can remove all of the remember picture options and add the following to automatically add remember to all pictures:
\tikzstyle{every picture}+=[remember picture]
You could (ab)use a table instead:
\documentclass{article}
\usepackage{multirow}
\begin{document}
\begin{tabular}{ll}
\textbullet Issue 1 & \multirow{2}{*}{{\LARGE \}} One and Two are cool} \\
\textbullet Issue 2 \\
\textbullet Issue 3 \\
\end{tabular}
\end{document}
produces:
removed dead Imageshack link
Here is Geoffs code with some small adaptions (just for other beamer users)
\begin{frame}{Example}
\begin{itemize}
\item The long Issue 1
\tikz[remember picture] \node[coordinate,yshift=0.7em] (n1) {}; \\
spanning 2 lines
\item Issue 2
\tikz[remember picture] \node[coordinate, xshift=1.597cm] (n2) {};
\item Issue 3
\end{itemize}
\visible<2->{
\begin{tikzpicture}[overlay,remember picture]
\draw[thick,decorate,decoration={brace,amplitude=5pt}]
(n1) -- (n2) node[midway, right=4pt] {One and two are cool};
\end{tikzpicture}
} % end visible
\end{frame}
Ressult (2nd slide of that frame):
The adaptions are:
added the visible command (because I think it is useful to blend in the brace later)
made the items more complex so the use of xshift became necessary (I figured out the xshift value simply by try and error so thats a drop of bitterness) Edit 2018-12-23: manual try-and-error shifting can be overcome by using this method: (n1 -| n2) -- (n2) instead of (n1) -- (n2).
One way to get around this would be to use a math environment like align, put the bullet points by hand (with \bullet ), and then use the resources of the math environment for big braces and such.
I did something similar once. I let the list be in a column to the left, and in the right column, I did the $\right\}$-thing so that it was as tall as some \mbox or something (which I decided with \vphantom or something similar). Unfortunately I don't have time to dig it out... I actually don't have time to be at SO at all right now ;)
I tried my idea, below. It doesn't work: unfortunately, the vboxes produced by the itemize environment all have width \textwidth.
The UI of my suggestion is nice, and by redefining \item it should be possible to get the item vboxes be of reasonable width. Or calculate a reasonable width for the vboxes containing the items. But since there are functional solutions already, I won't spend anymore time on this.
\documentclass{article}
\def\setgrouptext#1{\gdef\grouptext{#1}}
\newenvironment{groupeditems}{\begin{displaymath}\left.\vbox\bgroup\setgrouptext}{%
\egroup\right\rbrace\hbox{\grouptext}\end{displaymath}}
\begin{document}
\begin{itemize}
\item Line 1
\begin{groupeditems}{Lines 2 and 3 together!}
\item Line 2
\item Line 3
\end{groupeditems}
\item Line 4
\end{itemize}
\end{document}

Eliminate space before \begin{itemize} [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 4 years ago.
Improve this question
In Latex, how do I eliminate the space inserted before itemize?
\begin{itemize} % produces lots of vertical space
\item ...
\item ...
\end{itemize}
The way to fix this sort of problem is to redefine the relevant list environment. The enumitem package is my favourite way to do this sort of thing; it has many options and parameters that can be varied, either for all lists or for each list individually.
Here's how to do (something like) what it is I think you want:
\usepackage{enumitem}
\setlist{nolistsep}
or
\usepackage{enumitem}
\setlist{nosep}
Try \vspace{-5mm} before the itemize.
Use \vspace{-\topsep} before \begin{itemize}
Use \setlength{\parskip}{0pt} \setlength{\itemsep}{0pt plus 1pt} after \begin{itemize}
And for the space after the list, use \vspace{-\topsep} after \end{itemize}
\vspace{-\topsep}
\begin{itemize}
\setlength{\parskip}{0pt}
\setlength{\itemsep}{0pt plus 1pt}
\item ...
\item ...
\end{itemize}
\vspace{-\topsep}
The cleanest way for you to accomplish this is to use the enumitem package (https://ctan.org/pkg/enumitem). For example,
\documentclass{article}
\usepackage{enumitem}% http://ctan.org/pkg/enumitem
\begin{document}
\noindent Here is some text and I want to make sure
there is no spacing the different items.
\begin{itemize}[noitemsep]
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
\noindent Here is some text and I want to make sure
there is no spacing between this line and the item
list below it.
\begin{itemize}[noitemsep,topsep=0pt]
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
\end{document}
Furthermore, if you want to use this setting globally across lists, you can use
\usepackage{enumitem}% http://ctan.org/pkg/enumitem
\setlist[itemize]{noitemsep, topsep=0pt}
However, note that this package does not work well with the beamer package which is used to make presentations in Latex.
The "proper" LaTeX ways to do it is to use a package which allows you to specify the spacing you want. There are several such package, and these two pages link to lists of them...
TeX FAQ entry How to adjust list spacing
http://dcwww.camd.dtu.dk/~schiotz/comp/LatexTips/LatexTips.html
I'm very happy with the paralist package. Besides adding the option to eliminate the space it also adds other nice things like compact versions of the itemize, enumerate and describe environments.
\renewcommand{\#listI}{%
\leftmargin=25pt
\rightmargin=0pt
\labelsep=5pt
\labelwidth=20pt
\itemindent=0pt
\listparindent=0pt
\topsep=0pt plus 2pt minus 4pt
\partopsep=0pt plus 1pt minus 1pt
\parsep=0pt plus 1pt
\itemsep=\parsep}

Latex Multiline Equations

Is it possible to get multline like behavior within a gather
environment? I have a set of equations in a gather environment, but
one of them is too long, and I'd like to split it up onto two lines
where the first line is left-aligned and the second line is right-aligned
(just like multline). If there is a way of aligning individual lines
within the gather or split environment (like flushleft or flushright but
functional in mathmode) this would solve the problem.
The mathtools package has an inner multlined environment similar to gathered and the likes, but it required a small amount of manual tweaking:
\documentclass{article}
\usepackage{amsmath}
\usepackage{mathtools}
\begin{document}
% \begin{multline}
% \framebox[0.65\linewidth]{\strut} \\
% \framebox[0.6\linewidth]{\strut} \\
% \framebox[0.65\linewidth]{\strut} \\
% \framebox[0.6\linewidth]{\strut}
% \end{multline}
\begin{gather}
\framebox[0.8\linewidth]{\strut} \\
\begin{multlined}[b][\linewidth-3\multlinegap]
\framebox[0.65\linewidth]{\strut} \\
\framebox[0.6\linewidth]{\strut} \\
\framebox[0.65\linewidth]{\strut} \\
\framebox[0.6\linewidth]{\strut}
\end{multlined} \\
\framebox[0.4\linewidth]{\strut}
\end{gather}
\end{document}
I haven't tested this, but you can try putting \hfill in front of the second line.
Having said that: IMHO, multline behavior inside a gather environment is undesirable. Especially if you have the fleqn option enabled, you should consider the following option:
put the long equation inside a split, with alignment on the left side of the equality. Assuming the right hand side is too long, put its second part on a new line (still inside the split) and use \hspace{1cm} (or some other length) to indent the second part a bit further.
For an overview of all AMS multiline blocks, see the amsmath documentation.

Resources