[XeTeX] Large brace in multiline table cell

Axel Schlicht meiwakudome at web.de
Sun Oct 13 09:30:58 CEST 2013


Am 12.10.2013 14:39, schrieb BPJ:
> Can somebody help me on how to do the following with XeLaTeX,
> or, if this is not the right place to ask this, where I should
> ask this question?
>
> I need to set a text (not math) table with two
> columns where the left column contains linebreaks
> and a 'stretchy' right brace along the right edge of the cell,
> i.e. like so:
>
>      line 1  \
>      line 2  |   General description of what
>      line 3  >   kind of things the lines
>      line 4  |   in the left cell represent
>      line 5  /
>
>      More such rows with different numbers of lines
>      in the left cell.
>
> I use LaTeX and XeLaTeX regularly, but am not used to math stuff,
> so I'm out of my depth here. It's important that the text of the
> cells is set in the same fonts as the rest of the text. I doubt
> that the braces are really needed for clarity, but it's in my
> source so I have to reproduce it.
>
>
>
> --------------------------------------------------
> Subscriptions, Archive, and List information, etc.:
>   http://tug.org/mailman/listinfo/xetex
>

Hope this helps

################################################################

\documentclass{article}

\usepackage{colortbl,array} % colored tables, m-column
\usepackage{calc}           % used in setlength
\usepackage{fontspec}

\thispagestyle{empty}

\begin{document}
You can ``abuse'' math mode to achieve this. As you can see, a table
will be vertically centered with respect to the surrounding text.

However the p-column will top aligned to the text line of the right
box. So it will be ugly.

BUT, the braces will be much nicer -- that's not so fat.
\begin{center}
   \begin{tabular}{lp{3cm}ll}
     \hline
     $ \left. % empty left limiter
         \begin{tabular}{>{\columncolor{yellow}}l}
           line1 \\
           line2 \\
           line3 \\
           line4 \\
           line5
         \end{tabular}
       \right\} % brace to the right
    $ some text
    & other text, a little longer so it will require several lines to
      display, and give us some ugly horizontal alignment; that's why we
      use a p-column
    & more text
      $ \left\{
          \begin{tabular}{>{\columncolor{cyan}}r}
            line1 \\
            line2 \\
            line3 \\
            line4
          \end{tabular}
        \right.
      $ \\\hline
   \end{tabular}
\end{center}

Solution: use a m-column to align the explaining column.

\begin{center}
  \begin{tabular}{lm{3cm}ll}
    \hline
    $ \left.
        \begin{tabular}{>{\columncolor{yellow}}l}
          line1 \\
          line2 \\
          line3 \\
          line4 \\
          line5
        \end{tabular}
      \right\}
   $ some text
   & other text, a little longer so it will require several lines to
     display. In order to get a nice horizontal alignment why we now
     use an m-column from the array package
   & more text $ \left\{
        \begin{tabular}{>{\columncolor{cyan}}r}
          line1 \\
          line2 \\
          line3 \\
          line4
        \end{tabular}
      \right.
   $ \\\hline
  \end{tabular}
\end{center}

If the explaining column is to high you might want to fiddle with line
spacing in the tables. So we need the following (could also be done
manually, but this makes later changes easier.)

\newlength{\MyL} \setlength{\MyL}{1.75ex}
\newlength{\MyLl} \setlength{\MyLl}{\MyL*\real{1.75}}

\begin{center}
   \begin{tabular}{lm{3cm}ll}
     \hline
     $ \left.
         \begin{tabular}{>{\columncolor{yellow}}l}
           line1 \\[\MyL]
           line2 \\[\MyL]
           line3 \\[\MyL]
           line4 \\[\MyL]
           line5
         \end{tabular}
       \right\}
    $ some text
    & other text, a little longer so it will require several lines to
      display. In order to get a nice horizontal alignment why we now
      use an m-column from the array package
    & more text $ \left\{
         \begin{tabular}{>{\columncolor{cyan}}r}
           line1 \\[\MyLl]
           line2 \\[\MyLl]
           line3 \\[\MyLl]
           line4
         \end{tabular}
       \right.
    $ \\\hline
   \end{tabular}
\end{center}
\end{document}

################################################################

Axel Schlicht



More information about the XeTeX mailing list