TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to know how can I draw the line that appears in the right of the image below, and also how can I write this array that appears in the left of the picture.


share|improve this question
Can you add a minimal working example (MWE)? TikZ? PSTricks? What did you achieve so far? Where are your problems? – Qrrbrbirlbel Dec 17 '12 at 20:04
edited @Qrrbrbirlbel – Ahmed Mojaz Dec 17 '12 at 20:55
Welcome to TeX.sx! On this site, a question should typically revolve around an abstract issue (e.g. "How do I get a double horizontal line in a table?") rather than a concrete application (e.g. "How do I make this table?"). Questions that look like "Please do this complicated thing for me" tend to get closed because they are "too localized". Please try to make your question clear and simple by giving a minimal working example (MWE): you'll stand a greater chance of getting help. – Martin Schröder Dec 17 '12 at 20:58
Related for the |-| papth: Vertical and horizontal lines in pgf-tikz – Qrrbrbirlbel Apr 23 '13 at 1:04
up vote 8 down vote accepted

These are essentially two questions:

  1. The array.

    Use the array environment with a column specification of, for example, {c|c}.

    I wrapped this in a new environment sarray that adds the brackets (\left[ and \right]) and includes no additional \arraycolsep at the left and right side so that the brackets are tight. It takes one argument, the column specification, i.e. c|c.

    Another environment is Sarray that takes a count of columns, 6 becomes c|c|c|c|c|c. The optional argument can be used to change the columns from c to any column type (i.e. \begin{Sarray}[r]{5}.

    For the environments sarray and Sarray the column separator length is locally halved as this looks better in my eyes.

    Some examples can be found in the MWE below.

  2. The lines. I’d use Tik Z (→ ) for this.

    I provide the additional half- style for the to path operator. This style is a little bit optimized as it uses automatically .south for the start and .north for the target, as long as there’s neither . (node with anchor) or , (coordinate) in the start and target name.


\documentclass[tikz]{standalone}% loads tikz automatically, 
                                % in any normal class you'll need \usepackage{tikz}
    positioning,                % for left below=of
    shapes.arrows               % for the arrow
\newenvironment{sarray}[1]{     % #1 = column specifications, e.g. c|c|c
\newenvironment{Sarray}[2][c]{  % #1 = (optional, default = c) column specification
                                % #2 = number of columns
\def\qrr@pgfutil@add@anchor#1#2{% ... if node without anchor
    \qrr@pgfutil@in@,{#1}% -> coordinate
        \qrr@pgfutil@in@.{#1}% -> already node with anchor
\def\qrr@pgfutil@in@#1#2{% to save \expandafters for #2

  half-/.style={% this style automatically uses .south (for the start)
                %                           and .north (for the target node)
                % if no anchor is specified
    to path={
      (\tikztostart) -- (\pgf@xa, \pgf@ya) -| (\tikztotarget) \tikztonodes
\node (nSA1) {$\begin{sarray}{c|c}
                   0, 1, 2, 4, 5, 6, 7 & 3 \\
                   0, 1, 2, 4, 5, 6, 7 & 3

    below left=1cm and -1cm of nSA1
  ] (nSA2) {$\begin{Sarray}{4}% or \begin{sarray}{c|c|c|c}
                  0, 1, 2, 6 & 5, 7 & 4 & 3 \\
                  0, 1, 2, 6 & 5, 7 & 4 & 3

    below left=of nSA2
  ] (nSA3) {$\begin{Sarray}{6}% or \begin{sarray}{c*5{|c}}
                 0, 1, 2 & 6 & 7 & 5 & 4 & 3 \\
                 0, 1, 2 & 6 & 7 & 5 & 4 & 3

\node[% this is the arrow
    left=.5cm of nSA2,
    single arrow,
    minimum height=1cm
  ] {};

\draw[very thick] (nSA1) to[half-] node[pos=.75,left] {$4 \to 4$} (nSA2)
                  (nSA2) to[half-] node[pos=.75,left] {$5 \to 5$} (nSA3);

\draw (-4,0) to[half-] +(-1,-1);% works with normal coordinates, too.


enter image description here

share|improve this answer
thanks a lot, well done – Ahmed Mojaz Dec 18 '12 at 18:02

Your Answer


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.