14

I would like LaTeX to produce output like the following

example of a tabloid

(without the 2 a so called Young tabloid), ideally by writing

\ytabloidshort{123,56}

(using one character per cell, ideally allowing groups via brackets as in \ytabloidshort{89{10}{\ldots}{n+1},56}, but that is not important, the following is sufficient) or

\begin{ytabloid}
1 & 2 & 3 \\
4 & 5
\end{ytabloid}

of course with arbitrarily many rows and columns. The command/environment must (also or only) work in mathmode. That's why I included the 2 \cdot in the following examples.

I have found several ways to generate output similar to the desired, but they are all unacceptable.

\documentclass{article}

\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{ytableau}
\usepackage{tikz}
\usetikzlibrary{matrix}

\begin{document}

perfect, but I do not see a way to remove the vertical lines while keeping the 
horizontal ones (ytableau):
\[ 2 \cdot
\ytableausetup{centertableaux}
\begin{ytableau}
1 & 2 & 3 \\
4 & 5
\end{ytableau}
\]

matrix (amsmath) and cline:
\[ 2 \cdot
\begin{matrix}
\hline
1 & 2 & 3 \\ \hline
4 & 5 \\ \cline{1-2}
\end{matrix}
\]

matrix (amsmath) and cmidrule (booktabs):
\[ 2 \cdot
\cmidrulewidth=\lightrulewidth
\begin{matrix}
\midrule
1 & 2 & 3 \\ \midrule
4 & 5 \\ \cmidrule{1-2}
\end{matrix}
\]

tikzpicture and matrix (TikZ/PGF with library matrix):
\[ 2 \cdot
\begin{tikzpicture}
\matrix[matrix of math nodes] (m) {
1&2&3\\
4&5\\
};
\draw (m-1-1.north west) -- (m-1-3.north east);
\draw (m-1-1.south west) -- (m-1-2.south east);
\draw[red] (m-2-2.north west) -- (m-2-2.north east); % shows that lines don't overlap
\draw (m-2-1.south west) -- (m-2-2.south east);
\end{tikzpicture}
\]

\end{document}

Two (and more) disadvantages remain:

  • The output is ugly, actually unusable.
  • They are all very uncomfortable to write.

What do you suggest?

Is it, for example, possible to parse the argument of \ytabloidshort and draw a matrix, each cell with content automatically with a line above and below. (But note the "problem in red"). How would one implement such a \newcommand? Any other ideas are also welcome.

I can split this problem into three questions:

  1. How do I get tabloids whose appearance fits to tableaux generated with the package ytableau?
  2. How can I make the result of (1.) work in connection with other maths, cf. the 2 \cdot?
  3. How can I generate (1.) in a comfortable way?

Solutions so far:

Ryan extented his package ytableau to draw tabloids. As long as your are using the package, this solves all three questions. The picture above can be generated by

\usepackage{ytableau} % version 1.3 or higher

\ytableausetup{tabloids, centertableaux}
\[ 2 \cdot \ytableaushort{123,45} \]

Sticking to the questions the status is the following.

  1. Actually none. Spacing must be adapted.
  2. Actually none. Alignment and spacing must be adapted.
  3. Scott showed a way to generate the desired matrix by a makro. This is definitely worth noting and may be helpful in many other situations.
David Carlisle
  • 757,742
One
  • 1,485
  • 1
    With a syntax like \tabloidshort{123,56}, how would one distinguish between the first entry meaning 1,2,3, or 12,3, or 1,23, or 123? – Peter Grill Aug 14 '12 at 17:40
  • @PeterGrill: I think you can work with expl3 token list and clist. This simple as long as you have one digit per cell. – Marco Daniel Aug 14 '12 at 17:43
  • @Peter, Marco. Yes. I extended this part in the question a bit. But that's not the fundamental problem. – One Aug 14 '12 at 17:51
  • Hi Thomas, glad to see you here. We've talked about this by email, of course, and I never did implement it. Given its evident importance to you I will try to do that now. – Ryan Reich Aug 14 '12 at 21:48
  • That sounds perfect. It would complete your y*-package. Scott's solution works really well to produce the desired matrix. But I am already missing the smalltabloids option ... – One Aug 14 '12 at 22:21

4 Answers4

15

I've expanded ytableau a little to include an option to draw tabloids.

\documentclass{standalone}
\usepackage{ytableau}
\begin{document}
  \ytableausetup{tabloids,centertableaux}
  $2\cdot\ytableaushort{123,45,6}$
\end{document}

enter image description here

Currently the new version is on my website and has also been uploaded to CTAN.

Ryan Reich
  • 37,958
10

The ytableau package (by Ryan Reich) could be an option (examples take almost verbatim from the package documentation):

\documentclass{article}
\usepackage{amsmath}
\usepackage{ytableau}

\begin{document}

\ytableausetup{textmode}
\begin{ytableau}
a & d & f \\
b & e & g \\
c
\end{ytableau}

\ytableausetup{mathmode}
\begin{ytableau}
a & d & \ldots & f \\
b & e
\end{ytableau}

\[
\ytableausetup
{boxsize=1.25em}
\ytableausetup
{aligntableaux=top}
\ytableaushort[x_]{135,24,6}
+ \ydiagram[*(red!20) ]{3} \\
+ \ydiagram[*(blue!20)]{3,2,1}
= \ytableaushort[x_]{135,24,6}
*[*(red!20)]{3} *[*(blue!20)]{3,2,1}
\]

\end{document}

enter image description here

CTAN mentions two other packages associated to Young tabloids: youngtab and young, but ytableau is the most flexible and customizable one, as far as I could see.

If you don't like the rules, you can suppress them by saying

\makeatletter
\def\boxframe@YT{0.0em}
\makeatother

in the preamble.

Moriambar
  • 11,466
Gonzalo Medina
  • 505,128
  • 1
    I feel honored that people are now hacking my package :) – Ryan Reich Aug 14 '12 at 21:34
  • @Gonzalo Medina. Ryans package is wonderful for tableaux. Thanks for pointing out a way to remove the boxes at all. However, the question was how to remove the vertical lines while keeping the horizontal ones. – One Aug 14 '12 at 21:38
9

Here's an option. I'm not sure why you don't like the booktabs + matrix option, so you may not like this as well. However, it should give you an idea of how it can be implemented.

Edit 1: I removed a hardcoded value and added some of the booktabs constants into the function, you could fiddle with those to achieve spacing/weight that you like.

enter image description here

Edit 2: The case suggested in your comment should work now. This still requires the first row to be the longest however.

enter image description here

Edit 3: Removed hardcoded displayed math environment because, well, it was a bad idea.

\documentclass{article}
\usepackage{xparse}
\usepackage{booktabs}
\ExplSyntaxOn
\tl_new:N \l_my_body_tl
\int_new:N \l_first_row_count_int
\int_new:N \l_row_count_int
\int_set:Nn \l_row_count_int {1}
\cs_new:Npn \make_tab_row:n #1
    {
        \tl_clear:N \l_tmpa_tl
        \int_compare:nTF { \l_row_count_int = 1 }
          {
            \int_set:Nn \l_first_row_count_int {\tl_count:n {#1}}
            \int_set:Nn \l_tmpa_int {\tl_count:n {#1}}
          }
          {
            \int_set:Nn \l_tmpa_int {\tl_count:n {#1}}
          }
        \tl_set:Nx \l_tmpb_tl {\clist_item:Nn \g_tmpa_clist {\l_row_count_int + 1}}
        \int_set:Nn \l_tmpb_int {\tl_count:N \l_tmpb_tl}
        \int_set:Nn \l_tmpa_int {\int_max:nn \l_tmpb_int \l_tmpa_int}

        \tl_map_inline:nn {#1} {\tl_put_right:Nn \l_tmpa_tl {& ##1}}
        \tl_put_right:Nn \l_tmpa_tl {\\\cmidrule}
        \tl_put_right:Nx \l_tmpa_tl {{1-\int_to_arabic:n \l_tmpa_int}}
        \tl_set:Nx \l_tmpa_tl { \tl_tail:N \l_tmpa_tl }
        \tl_put_right:NV \l_my_body_tl \l_tmpa_tl
        \int_incr:N \l_row_count_int
    }

\NewDocumentCommand {\tabloidshort} { m }
    {
        \heavyrulewidth=.08em
        \cmidrulewidth=.08em
        \belowrulesep=.65ex
        \aboverulesep=.4ex
        \clist_gset:Nn \g_tmpa_clist {#1}
        \clist_map_function:nN { #1 } \make_tab_row:n
         \begin{array}{*{\int_use:N \l_first_row_count_int}{c}}
            \toprule
            \tl_use:N \l_my_body_tl
        \end{array}
        \tl_clear:N \l_my_body_tl
        \int_zero:N \l_first_row_count_int
        \int_set:Nn \l_row_count_int {1}
    }
\ExplSyntaxOff


\begin{document}

$\tabloidshort{12{10}5,1{\cdots}3,12}$

\[
\tabloidshort{89{10}{\ldots}{n+1},56}
\]

\begin{equation}
\tabloidshort{123,4,5,67}
\end{equation}

\end{document}
Scott H.
  • 11,047
  • This version of tabloidshort is indeed pleasant to use. Thank you very much. I will look at this in detail as I have not yet worked with xparse.
  • The appearence of the booktabs-suggestions does not fit to ytableaushort, it would at least require some adapted spacing.
  • – One Aug 14 '12 at 21:34
  • It should be possible to make this suggestion even more flexible: Can the line over the 7 in \tabloidshort{123,4,5,67} be added, i.e. can \cmidrule consider the length of the following line? – One Aug 14 '12 at 21:42
  • I am going to hate you next year when I get the bug to overhaul my package, now that I am aware how efficient LaTeX3 is for this purpose. – Ryan Reich Aug 15 '12 at 01:52
  • @RyanReich It does make things surprisingly pleasant at times :) – Scott H. Aug 15 '12 at 02:16