TransWikia.com

Multi-line curly brackets in a (text mode) table

TeX - LaTeX Asked by T F on April 9, 2021

Here’s my problem:

sample

In the attached sample the second column of the table contains multi-line curly brackets whose hetght matches the number of lines of the fifth column: if there are four items in the fifth column the bracket will be taller than when there are two, etc.

I found an example of code that does this nicely in let’s call that… running text e.g. outside a table:

documentclass[10pt]{extarticle}
usepackage[a6paper,verbose]{geometry}
begin{document}
I want to buy
$left{
begin{tabular}{@{}l@{}}
    tomatoes 
    onions 
    cucumbers
end{tabular}
right.
end{document}

I’ve been trying to integrate this to the otherwise basic table (five columns, a bit of multirow to vertically center the stuff in the first column… etc. ) in the attached jpg image for the last couple of nights but so far all I get is error messsages from xelatex.

Here’s a failing example among many:

documentclass[10pt]{extarticle}
usepackage[a5paper]{geometry}
usepackage{multirow}

begin{document}
begin{center}
begin{tabular}{ll}
                             &                                                     
multirow{2}{*}{SOUPIÈRES.}  & multirow{2}{*}{ left{ begin{tabular}{@{}l@{}}
                                   2  & — & potage d'esturgeon à l'anglaise.  
                                   2  & — & consommé à la Colbert.                      
                              end{tabular} right.}                               
                             &                                                     
end{tabular}
end{center}
end{document}

Any idea what’s wrong with this code and how to fix it?

Update 8/11/20

Thanks to Azeti’s help here’s a fixed version of my code (abridged):

documentclass[10pt]{extarticle}
usepackage[a5paper]{geometry}
usepackage{multirow}

begin{document}
begin{tabular}{ll}                              
                  &                                                      
                  &  begin{tabular}{|r|c|l|}                                    
                               40  & — & assiettes d'huîtres et citrons
                    end{tabular}                                                                     
                  &                                                      
  SOUPIÈRES.      & $ left{ begin{tabular}{|r|c|l|}                                    
                                2  & — & potage d'esturgeon à l'anglaise.            
                                2  & — & consommé  à la Colbert. 
                              end{tabular} right.$                                                  
                  &                                                      
  HORS-D'ŒUVRE.   & $ left{ begin{tabular}{|r|c|l|}                                    
                                2  & — & quenelles de volaille à la Villeroi.        
                                2  & — & rissoles de gibier.                         
                              end{tabular} right.$                                                  
                  &                                                      
  POISSONS.       & $ left{ begin{tabular}{|r|c|l|}                                    
                                2  & — & turbot sauce aux anchois.                   
                                2  & — & rougets grillés.                           
                              end{tabular} right.$                                                  
                  &                                                      
  RELEVÉS.        & $ left{ begin{tabular}{|r|c|l|}                                    
                                2  & — & pièce de bœuf à la nivernaise.              
                                2  & — & jambon glacé au madère.                   
                              end{tabular} right.$                                                  
                  &                                                      
  ENTRÉES.        & $ left{ begin{tabular}{|r|c|l|}                                    
                                2  & — & petits pâtés à la financière.               
                                2  & — & chartreuse de perdreaux.                    
                                2  & — & queues de langoustes belle-vue.             
                                2  & — & aspic de foie-gras.                      
                              end{tabular} right.$                                                  
end{tabular}
end{document}

Now the problem with the right half of the table being in a bunch of independent nested tables is that the columns are no longer aligned: i.e. the numbers in column 3, the em-dashes in column 4 and the two-four lines of text in the right-most column. This sample should compile with xelatex if anyone cares to have a look.

In order to try to fix this I changed the tabular column specs from rcl to p{length)… etc. to force the same width for all the nested tables and this somewhat improves the layout but some columns are still slightly misaligned for some reason (I vaguely suspect this may be due to overfull boxes and such like).

I didn’t find anything that would force latex/xelatex to align the columns of identical table that live in the same page no matter what.

So it looks like a choice between trying my luck with Bernard‘s more exotic packages and just doing away with these rather ugly braces which in my limited experience… 19th century printers & typesetter in France appear to have been overly fond of.

Not holding my breath, but if anyone has further suggstions…

Update 8/17/20

Eventually went with Bernard’s solution and the blkarray package… more scalable than nested tables (e.g. imagine something that has a large opening curly brace with a few second level smaller curly braces that have yet a few third level curly braces etc. etc.). Not going to happen? Think again:

Is coding multi-line curly braces in text mode possible?

2 Answers

It can be done in a simple way, with the blkarray package, and some complementary packages (booktabs, stackengine):

documentclass[10pt]{extarticle}
usepackage[a5paper]{geometry}
usepackage[T1]{fontenc}
usepackage{ebgaramond}
usepackage{multirow}
usepackage{array, blkarray}
usepackage{booktabs}
usepackage[usestackEOL]{stackengine}

begin{document}


begin{center}
setlength{BAextrarowheight}{3pt}
begin{blockarray}{l@{}l@{enspace}l}
                           40 & & Assiettes d’huîtres et citrons 
addlinespace
        begin{block}{Left{scshape soupières. }{{}l@{}l@{enspace}l}%
                                   2 & — & Potage d'esturgeon à l'Anglaise. 
                                   2 & — & Consommé à la Colbert. 
        end{block}
addlinespace
        begin{block}{Left{scshapeCenterstack{hors-d’œuvre.} }{{}l@{}l@{enspace}l}%
                                   2 & — & Quenelles de volailles à la Villeroi. 
                                   2 & — & Rissoles de gibier. 
        end{block}
addlinespace
        begin{block}{Left{scshape Poissons. }{{}l@{}l@{enspace}l}%
                                   2 & — & Turbot sauce aux anchois. 
                                   2 & — & Rougets grillés. 
        end{block}
addlinespace
end{blockarray}
end{center}

end{document} 

enter image description here

Answered by Bernard on April 9, 2021

Here is a solution with {NiceTabular} of nicematrix. With that environment, you construct your tabular, and, after, you put the braces where you want (you need at least v 5.10).

documentclass[10pt]{extarticle}
usepackage[a5paper]{geometry}
usepackage{ebgaramond}

usepackage{nicematrix}

begin{document}
begin{NiceTabular}{cr@{;}l@{;}l} 
 & 40  &   & Assiettes d'huîtres et citrons       [1ex]
Block{2-1}{SOUPIÈRES.} 
 &  2  & — & Potage d'esturgeon à l'Anglaise.     
 &  2  & — & Consommé  à la Colbert.              [1ex]
Block{2-1}{HORS-D'ŒUVRE.}   
 & 2  & — & Quenelles de volaille à la Villeroi. 
 & 2  & — & Rissoles de gibier.                  [1ex]
Block{2-1}{POISSONS.} 
 & 2  & — & Turbot sauce aux anchois.            
 & 2  & — & Rougets grillés.                     [1ex]
Block{2-1}{RELEVÉS.} 
 & 2  & — & Pièce de bœuf à la Nivernaise.       
 & 2  & — & Jambon glacé au madère.              [1ex]
Block{4-1}{ENTRÉES.} 
 & 2  & — & Petits pâtés à la Financière.        
 & 2  & — & Chartreuse de perdreaux.             
 & 2  & — & Queues de langoustes Belle-Vue.      
 & 2  & — & Aspic de foie-gras. 
CodeAfter
SubMatrix{{2-2}{3-2}.
SubMatrix{{4-2}{5-2}.
SubMatrix{{6-2}{7-2}.
SubMatrix{{8-2}{9-2}.
SubMatrix{{10-2}{13-2}.
end{NiceTabular}
end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes).

Output of the above code

Answered by F. Pantigny on April 9, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP