6

I would like to draw the kind of table (I don't know any proper name for this, so I cannot research for similar question) shown in the picture below:

table

I have absolutely no clue on how I can draw it. Do you know any package/simple way to draw it? If possible, what the macro should draw a vertical bar on each side, plus any number of smaller vertical lines inside the "table". The content of each part will always be in the form $a \dots a$, with one symbol on each side and the space in between filled by dots (potentially more than 3 dots). One bracket below every part, on all its length (or slightly smaller for esthetic reason). No bracket above or on the sides.

This looks similar to a tabular environment but:

  1. How can I obtain vertical lines with different heights?
  2. How can I obtain the below brackets?

As you can guess, I cannot provide a MWE.

  • Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document. At the very least, you can provide the basic structure for a document and sample content for the table even if you do not know what environment to put it in. – cfr Jun 10 '14 at 3:03
  • My browser took 15 seconds to load the (useless) upper 50% of the embedded image before it just gave up. How come it needs to be 8 megapixels, exactly? – hftf Jun 10 '14 at 3:21
  • 1
    @cfr I find the question polite and relevant. It must be allowed to ask a question event if you have no clue where to start. Then we can give some hint, and advise the OP to come back with further questions and a M(N)WE. – Sveinung Jun 10 '14 at 9:14
  • 1
    @Taladris That means anybody who wants to help has to type out the document from scratch, copying the picture. That is a lot more work than copy-and-pasting code and requires multiple helpers to duplicate efforts. Help potential helpers to help you by doing what you can, even if you don't know if the final solution will be a tabular or not. – cfr Jun 10 '14 at 14:06
  • 1
    @Sveinung But even somebody with little idea where to start can provide \documentclass... etc. and that is the first step towards any solution. It is about asking somebody to do whatever they can - something which will obviously vary greatly depending on knowledge and experience. That variation is fine but anybody asking how to typeset an image (as opposed to struggling to install TeX or similar) can take the first step. I never suggested (and do not think) that the question was impolite or irrelevant. If I did, I would not have left that comment. – cfr Jun 10 '14 at 14:09
7

Some low level programming. ;-)

\documentclass{article}

\newcommand{\scheme}[3][6em]{%
  \leavevmode\vtop{\offinterlineskip\tabskip=0pt
    \setlength{\schemewidth}{#1}%
    \global\firstrowtrue
    \halign{\vrule depth\dp\strutbox##&&\makeschemecell{##}\cr
      &#2&\omit\vrule\cr
      \noalign{\global\firstrowfalse\hrule}
      \omit&#3&\omit\cr
    }%
  }%
}
\newcommand\makeschemecell[1]{%
  \iffirstrow
    \kern3pt
    \makebox[\schemewidth][s]{$#1\cdotfill#1$}%
    \kern3pt\vrule height3pt\kern-0.4pt
  \else
    \kern3pt
    $\underbrace{\makebox[\schemewidth]{}}_{#1}$%
    \kern3pt
  \fi
}
\makeatletter
\newcommand\cdotfill{%
  \leavevmode\cleaders\hb@xt@.44em{\hss$\cdot$\hss}\hfill\kern\z@
}
\makeatother

\newif\iffirstrow
\newlength{\schemewidth}

\begin{document}

\scheme{a&b}{E&F}

\scheme[3em]
  {a&b&c&d}
  {E&F&G&H}

\end{document}

enter image description here

5

I only have a quick'n'dirty solution (gotta run). I didn't know how to make a "short" vertical line, so instead I made each table cell very short, so the content hangs out the top. Then a double row looks like one, and a single row looks like a short rule.

It's in no way generalised for a different number of "columns", but changing the number of inputs isn't too hard. (Looping over an undetermined number of them is a bit harder.)

I hope someone comes up with a better solution than mine :)

\documentclass[a4paper]{article}
\usepackage{array}
\begin{document}

\def\foo#1#2#3#4{%
  \begingroup
  \setlength\extrarowheight{-1.5ex}
  \def\y##1##2{\multicolumn{1}{c}{\smash{$\underbrace{\phantom{##1}}_{##2}$}}}
  \begin{tabular}{|cc|}
  &\\
  \multicolumn{1}{|c|}{\smash{$#1$}} & \smash{$#2$} \\
  \hline
  \y{#1}{#3} &
  \y{#2}{#4} \\
  \end{tabular}
  \endgroup
}

\foo{a\dots\dots a}{b\dots b}{E}{F}

\end{document}
  • Beautifully smart and useful, here is implemented. – Hans Jun 10 '14 at 4:06
  • I will wait a short time for a "cleaner" answer before accepting but your answer already fill my needs. – Taladris Jun 10 '14 at 4:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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