6

In my documents, I have found that when I call \upbracefill in a tabular cell, the resulting brace IS NOT taking the entire width of the cell.

After creating the smallest example I could that produces this behavior (appended below), I have found that the problem has been the inclusion of the package colortbl.

When I remove this package from one of my documents, the brace resulting from \upbracefill DOES FILL the entire width of the cell.

For my documents, however, I need the package colortbl.

Attached is an example which replicates this behavior. You can try building this small document both ways, with and without the line \usepackage{colortbl}.

I need the normal behavior of \upbracefill to fill an entire cell. How can I do this with the package colortbl?

I am using LaTeX Version 3.1415926-2.6-1.40.14 (TeX Live 2014/dev)

\documentclass[letterpaper]{book}

\usepackage{colortbl} % TRY COMMENTING THIS OUT, TOO

\begin{document}

\begin{tabular}{  l llll llll }

letters: & a  & b & c & d & e & f & g & h  \\

blah          & \multicolumn{8}{c}{\upbracefill}    \\
blah          & \multicolumn{8}{l}{\upbracefill}    \\
\end{tabular}

\end{document}

2 Answers2

3

You can construct this \upbracefill manually:

enter image description here

\documentclass{article}

\usepackage{colortbl}

\begin{document}

\begin{tabular}{ *{9}{l} }
  letters: & a  & b & c & d & e & f & g & h  \\
  blah     & \multicolumn{8}{c}{\raisebox{.5\normalbaselineskip}[0pt][0pt]{$\underbrace{\phantom{abcdefgh}\hspace*{14\tabcolsep}}$}} \\
  blah     & \multicolumn{8}{l}{\raisebox{.5\normalbaselineskip}[0pt][0pt]{$\underbrace{\phantom{abcdefgh}\hspace*{14\tabcolsep}}$}} \\
\end{tabular}

\end{document}

Using a \phantom hides the equivalent column entries, while there are 2 \tabcolseps between each column. If the measurements become a little unwieldy, you can insert lengths to roughly match the width, like \hspace*{12.5em} in this case:

enter image description here

\documentclass{article}

\usepackage{colortbl}

\begin{document}

\begin{tabular}{ *{9}{l} }
  letters: & a  & b & c & d & e & f & g & h  \\
  blah     & \multicolumn{8}{c}{\raisebox{.5\normalbaselineskip}[0pt][0pt]{$\underbrace{\phantom{abcdefgh}\hspace*{14\tabcolsep}}$}} \\
  blah     & \multicolumn{8}{l}{\raisebox{.5\normalbaselineskip}[0pt][0pt]{$\underbrace{\hspace*{12.5em}}$}} \\
\end{tabular}

\end{document}

For more on horizontal widths, see What commands are there for horizontal spacing?

Werner
  • 603,163
  • Mr. Grundlingh, please take a look at https://groups.google.com/forum/?hl=en#!topic/latexusersgroup/i-v1f3dVLjc – Josef J. Sep 20 '14 at 03:11
  • Thank you for your suggested work arounds. In addition, someone from latexproject.org sent me another work around, using the following command to make a bracket fill up an entire cell:

    \def\hfill{\hskip0pt plus 1filll}\upbracefill

    It can be confirmed that the package colortbl currently breaks \upbracefill, though colortbl currently is not part of the core latex release.

    – Josef J. Sep 26 '14 at 21:28
0

With {NiceTabular} of nicematrix.

\documentclass[letterpaper]{book}
\usepackage{nicematrix}
% \usepackage{colortbl} % the output is the same with or without colortbl

\begin{document}

\begin{NiceTabular}{*{9}{l}} letters: & a & b & c & d & e & f & g & h \ blah & \ blah & \ \CodeAfter \UnderBrace[yshift=-2mm]{1-2}{2-9}{} \UnderBrace[yshift=-2mm]{1-2}{3-9}{} \end{NiceTabular}

\end{document}

The output is the same with or without the package colortbl (however, nicematrix has its own tools to color cells, rows and columns).

Output of the above code

F. Pantigny
  • 40,250