Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.
share|improve this question
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. –  Thomas 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 ... –  Thomas Aug 14 '12 at 22:21

4 Answers 4

up vote 12 down vote accepted

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.

share|improve this answer

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}
share|improve this answer
    
3. 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. 1. The appearence of the booktabs-suggestions does not fit to ytableaushort, it would at least require some adapted spacing. –  Thomas 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? –  Thomas 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 1:52
    
@RyanReich It does make things surprisingly pleasant at times :) –  Scott H. Aug 15 '12 at 2:16

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.

share|improve this answer
    
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. –  Thomas Aug 14 '12 at 21:38

This was actually an exercise for me to learn xstring and etoolbox functions a little bit better so the end result is not polished and there is no optimization of any sort. Also there is a space on the left side when used inline. I can't see why.

The syntax is simply a comma seperated list which should be terminated by an additional comma otherwise the last entry is omitted.

\documentclass[12pt]{article}
\usepackage{xstring,tikz,etoolbox}
\usetikzlibrary{matrix}
\newcommand{\youngtab}[1]{%
\def\youngrowlist{#1}%
    \StrCount{\youngrowlist}{,}[\rownum]%
    \foreach \x in {1,...,\rownum}{%
        \StrBefore{\youngrowlist}{,}[\mynextrow]%
        \StrLen{\mynextrow}[\numlength]%
        \csxdef{rowlen\x}{\numlength}%
        \csxdef{row\x}{\mynextrow}%
        \StrGobbleLeft{\youngrowlist}{\number\numexpr\numlength+1\relax}[\mytemplist]%
        \xdef\youngrowlist{\mytemplist}%
        \let\mytemplist\empty%
        \csgdef{rowconcat\x}{}%
        \foreach \y in {1,...,\numlength}{%
            \StrChar{\csuse{row\x}}{\y}[\nextdigi]%
            \edef\mytemplist{\csuse{rowconcat\x}\nextdigi\relax}%
            \csxdef{rowconcat\x}{\mytemplist\&\relax}%
        }
    }
    \foreach \x in {1,...,\rownum}{
     \begingroup\edef\pfff{\endgroup%
         \noexpand\gappto\noexpand\mymatrixcontent{\csuse{rowconcat\x}\noexpand\\}}\pfff
    }%
    \tikz[baseline=(m.center)] {\matrix (m) [matrix of math nodes,ampersand replacement=\&] {\mymatrixcontent};
    \draw \foreach \x in {1,...,\rownum}{(m.west |- m-\x-1.south west) -- (m-\x-\csuse{rowlen\x}.south east)};
    \draw (m.west |- m-1-1.north west) -- (m-1-\csuse{rowlen1}.north east |- {{m.west |- m-1-1.north west}});}%
    \let\mymatrixcontent\empty
    \let\youngrowlist\empty
}

\begin{document}
Spelling tableau \youngtab{789c,a3\%,45687,r,} correctly is very difficult so we populate this line with wise 
words to see the vertical placement. Then an equation follows: 
\begin{equation}
2\cdot \youngtab{1453,{\cdots}4,45687,6,68,}
\end{equation}
The rows are drawn but should it follow the the upper and the lower rows if they are longer, I don't know yet. 
\end{document}

enter image description here

However, I think a pgfplotstable solution that is working inside a macro, should also be considered.

share|improve this answer
    
The options to the matrix and its nodes can be passed along with another argument to the macro. –  percusse Aug 15 '12 at 1:04
    
My constructive criticism: I have long thought that if I wrote v2.0 of my package I would do it in PGF somehow. Unfortunately, the strengths of PGF do not address the little things that need to be done for making this kind of diagram: keeping all the rows the same height, parsing the input, avoiding mysterious spaces...I don't know how to say this without approaching bad taste since I am the one with the package, but it's just not that simple to throw together something like this that works. –  Ryan Reich Aug 15 '12 at 1:39
    
@RyanReich Sure, I agree about the tiny details that requires a lot of attention and this is not even a full working solution. I just wanted to see if it is possible with some concise construction. But still, coming from other direction, I have to say that it can not be that complicated since it's just a table with rules. –  percusse Aug 15 '12 at 9:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.