Latex: stretchable curly braces outside math - latex

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}

Related

How to align an enumerated list in 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

LaTex items left alignment in resume writing

I am trying to write a resume with LaTex. Does anyone know how to left flush items? The code I use is
\documentclass[11pt, letterpaper]{article}
\usepackage[letterpaper, margin=0.75in]{geometry}
\usepackage{mdwlist}
\usepackage{sectsty}
\allsectionsfont{\centering}
\newcommand{\headerrow}[2]
{\begin{tabular*}{\linewidth}{l#{\extracolsep{\fill}}r}
#1 &
#2 \\
\end{tabular*}}
\begin{document}
\hrule
\vspace{-0.4em}
\subsection*{experience}
\begin{itemize}
\item[]
\headerrow
{\textbf{Teaching Inc.}}
{\textbf{Chicago, IL}}
\\
\headerrow
{\emph{Look and See}}
{\emph{Vision}}
\begin{itemize*}
\item This is A
\item This is B
\end{itemize*}
\end{itemize}
\end{document}
And I get a results like
My question is, how can I left flush those items to align with the horizontal line. No indent and make them similar to the right flushed "Chicago, IL" and "vision". Thank you!
The left indent is created by your first itemize environment. Since you don't use the item symbols, you should remove it and everything would be flushed to the left.
With this code there is no left indent :
\documentclass[11pt, letterpaper]{article}
\usepackage[letterpaper, margin=0.75in]{geometry}
\usepackage{mdwlist}
\usepackage{sectsty}
\allsectionsfont{\centering}
\newcommand{\headerrow}[2]
{\begin{tabular*}{\linewidth}{l#{\extracolsep{\fill}}r}
#1 &
#2 \\
\end{tabular*}}
\begin{document}
\hrule
\vspace{-0.4em}
\subsection*{experience}
\headerrow
{\textbf{Teaching Inc.}}
{\textbf{Chicago, IL}}
\\
\headerrow
{\emph{Look and See}}
{\emph{Vision}}
\begin{itemize*}
\item This is A
\item This is B
\end{itemize*}
\end{document}
If you really want to keep the items, a lot of solutions are proposed here : How to disable indentation of LaTeX list items?
NOTE : this question should be on https://tex.stackexchange.com/

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: text should automatically fill the frame in Beamer slides

In beamer frames I want the contents to be spread out evenly across the frame.
Using option \documentclass[slidestop]{beamer} I can easily specify the contents to be top/center aligned but when I have only few bullets on a slide they get clustered together at the top, I want beamer to decide the spacing between them automatically to spread them evenly.
Is this possible without putting vspace by trial and error?
I think using \vfill would reduce the trial and error part. One \vfill between each bullet should guarantee even spacing. Try \vfill before and/or after bullets to get separation from preceding text or from bottom of page. I don't use or know Beamer, but I suspect there's a way to put the \vfill commands into the Beamer template.
\documentclass{article}
\begin{document}
\begin{itemize}
\vfill\item This is text of first item
\vfill\item This is text of second item
\vfill\item This is text of third item
\end{itemize}
\end{document}
Per your comment, here's one way you could define vfill to be automatically used in main list items but have no vfill in subitems. THis way lets you use same \item command regardless of whether you're in main list or in nested list, but requires you to define or redefine environments, and to be aware of when you're adding a main (i.e, vfilled) list and when you're adding a non-vfilled (i.e, nested) list:
\documentclass{article}
\newenvironment{novfillenum}{\begin{enumerate}\let\item\olditem}%
{\end{enumerate}}
\newenvironment{vfilleditems}{\begin{itemize} \let\olditem\item \renewcommand\item{\vfill\olditem}}%
{\end{itemize}}
\begin{document}
\begin{vfilleditems}
\item Item One
\begin{novfillenum}
\item subitem1
\item s2
\item s3
\end{novfillenum}
\item Item Two
\begin{novfillenum}
\item subitem1
\item s2
\item s3
\end{novfillenum}
\item item three
\begin{novfillenum}
\item subitem1
\item s2
\item s3
\end{novfillenum}
\end{vfilleditems}
\end{document}
Adding another sample here because first answer getting too crowded. Tested altering the label commands and, what do you know, it seems to work, sort of. It gives errors, though, which I'm sure are related to having the \vfill as part of the label construct. I'm surprised it does seem to create the desired output, but the method would need some tweaking to get it to work without errors:
\begin{document}
\let\oldlabelitemi\labelitemi
\renewcommand{\labelitemi}{\vfill\oldlabelitemi{\hspace{1ex}}}
\begin{itemize}
\item Item One
\begin{itemize}
\item subone
\item subtwo
\item subthree
\end{itemize}
\item Item Two
\begin{itemize}
\item subitem1
\item s2
\item s3
\end{itemize}
\item item three
\begin{itemize}
\item subitem1
\item s2
\item s3
\end{itemize}
\end{itemize}
\end{document}

tikz: set appropriate x value for a node

This question resulted from the question here
I want to produce a curly brace which spans some lines of text.
The problem is that I have to align the x coordinate manually, which is not a clean solution.
Currently I use
\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}
which produces the desired result:
The unsatisfying thing is, that I had to figure out the xshift value of 1.597cm by trial and error (more or less)
Without xshift argument the result is:
I guess there is an elegant way to avoid the explicit xshift value.
The best way would it imho be to calculate the maximum x value of two nodes and use this, (as already suggested by Geoff)
But it would already be very handy to be able to explicitly define the absolute xvalues of both nodes while keeping their current y values. This would avoid the fiddly procedure of adapting the third post decimal position to ensure that the brace looks vertical.
This requires \usetikzlibrary{calc}. There may be a cleaner way, though.
Remove the "xshift" from node n2 and then use:
\begin{tikzpicture}[overlay,remember picture]
\path (n2) -| node[coordinate] (n3) {} (n1);
\draw[thick,decorate,decoration={brace,amplitude=5pt}]
(n1) -- (n3);
\node[right=4pt] at ($(n1)!0.5!(n3)$) {One and two are cool};
\end{tikzpicture}
Here's a version using the fit library which doesn't require you to worry about which line is longest, at the expense of marking each line.
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{fit}
\newcommand{\bracemark}[1]{\tikz[remember picture] \node[inner sep=0pt] (#1) {\vphantom{X}};}
\begin{document}
\begin{frame}{Example}
\begin{itemize}
\item The long Issue 1 \bracemark{n1} \\
gratuitious long line of text \bracemark{n2} \\
spanning 3 lines \bracemark{n3}
\item Issue 2 \bracemark{n4}
\item Issue 3
\end{itemize}
\visible<2->{
\begin{tikzpicture}[overlay,remember picture]
\node [inner sep=0pt, fit=(n1) (n2) (n3) (n4)] (bracemarks) {};
\draw[thick,decorate,decoration={brace,amplitude=5pt}]
(bracemarks.north east) -- (bracemarks.south east) node[midway, right=4pt] {One and two are cool};
\end{tikzpicture}
} % end visible
\end{frame}
\end{document}
The yshift needed in the OP's sample is avoided by making the nodes actual nodes (as opposed to coordinates) with a zero-width X as text.

Resources