I'm trying to create two bulleted list divided into categories by braces.
Something like that:
I searched on Google and I found some questions about it, for example: How can I create a brace spanning multiple lines on the right side of an itemized list? and How to put curly brace in front of even number of bullets?.
So this is the code I produced:
\documentclass[notoc,numbers]{tufte-book}
\usepackage{amsmath}
\begin{document}
\begin{itemize}
\item DTP
\item HIB
\item MMR $\smash{\left.\rule{0pt}{.4\dimexpr5\baselineskip+5\itemsep+4\parskip}\right\}
\text{1981-2017}}$
\item POL
\item HEP B $\smash{\left.\rule{0pt}{.1\dimexpr1\baselineskip+0\itemsep+0\parskip}\right\}
\text{1992-2017}}$
\end{itemize}
and:
\begin{itemize}
\item Diphteria
\item Measles
\item Mumps
\item Pertussis \smash{\raisebox{.8\dimexpr\baselineskip+\itemsep+\parskip}{%
$\left.\rule{0pt}{.8\dimexpr4\baselineskip+3\itemsep+3\parskip}\right\}$
1981-2016}}
\item Polio
\item Rubella
\item Tetanus
\end{itemize}
\end{document}
The result:
There is some mistake but I do not understand how to solve it.
Thank you
Best Answer
I really suggest that you use one of the Tikz solutions to the questions you have linked. However, with your current approach, what you should do is this:
Let's think about why this works:
\smash
: "As the name implies,\smash
takes its contents and prints it as if its height and depth were zero" (source). Here it means that you can have a very large brace without it affecting the surrounding text.\left. ... \right\}
: With\left
and\right
you print delimiters that are large enough to contain whatever is printed between them. For the first delimiter we choose.
which means "no delimiter" (so we just use it to define the area that is used to define the height), and for the second one a brace. So we need to put something in between that is large enough to force the brace to have the desired height.\rule{0pt}{...}
: This prints a rule of zero width, i.e. it doesn't print a visible rule but still reserves the height of the rule specified by the second argument..5\dimexpr4\baselineskip+3\itemsep+3\parskip
: This is not as complicated as it looks. We just sum four times the\baselineskip
(the height of a regular text line), three times the\itemsep
(the additional distance between two items) and three times the\parskip
(the usual space between two paragraphs). The sum gives the full height of four lines of items. Half of this sum is taken as height of the invisible\rule
. Why half? Because the rule has no depth, i.e. doesn't go below the baseline, the brace takes however the same space above and below the baseline. So to get a brace as high as four lines of items, you need to have the rule of half of that height. (Try\rule{1pt}
to visualize this)\raisebox{...}{...}
: This lifts the text given as second argument by the height given as first argument. Why do we need this? In the second list, you want to span an odd number of items, so putting the brace on the middle item gives you directly the right position. In the first list, however, you want to span an even number of items. So if you put it to the third\item
, it will be half a line to low..5\dimexpr\baselineskip+\itemsep+\parskip
: Thus, this is the height by which you want the first brace to be lifted: The half of: height of regular line + space between two paragraphs + additional space between two items.Now, when you go to other examples with different number of
\item
s that you want to span, here is what you have to think about:\}
.\smash
and\rule{0pt}
parts, and take as height.5\dimexprX\baselineskip+Y\itemsep+Y\parskip
whereX
is the number of items andY
is one less. Never change the.5
in front!\raisebox{.5\dimexpr\baselineskip+\itemsep+\parskip}
part, but you don't need to touch the heights here!