I've google a bit about this topic but I've found no result.

I'm trying to write some notes for my University course. The topic is "numerical interpolation methods". More precisely I have to build a table of "finite differences" (here a description, about at mid page you can see a table of values which are "triangular", that's what I have to do) which is pretty easy to do with the \multirow{n}*{text} command.

What I need though is to add a line that "links", say, the first cell in the first column with the second cell in the second column. How would I do that?

Here's an example, you can see lines going from one cell to another.

An example

  • 2
    Which package provides the command \multiline? Can you provide a minimal example? – Marco Daniel Oct 23 '11 at 11:27
  • 1
    With "links", do you mean you want to draw a line from one cell to another cell? Could you maybe make an example using a drawing program, so people get an idea what exactly your desired result looks like? – Jake Oct 23 '11 at 11:28
  • 1
    Sorry, I made a mistake, it was \multirow, provided by the package multirow. I'll make a drawing to explain better. I cannot provide a MWE because I don't know how to do it, that's what I'm asking help for. :P – mmassaro Oct 23 '11 at 11:50
  • Try \searrow and \nearrow. – Yiannis Lazarides Oct 23 '11 at 14:56

Here is an example using pst-node (from the pstricks bundle) and array (for the m{<len>} column type). Nodes are marked via \pnode(<x>,<y>){<name>} and lines are drawn using \psline(<node1>)(<node2>).

enter image description here

\usepackage{pst-node}% http://ctan.org/pkg/pstricks
\usepackage{array}% http://ctan.org/pkg/array
    $x$ & 
    $f$ & 
    I~diff. & 
    II~diff. & 
    III~diff. \\[\jot]
      x_0 \\ x_1 \\ x_3
    \end{array}$ &
      f(x_0)\pnode(0.5ex,0.6ex){fx0} \\ f(x_2) \\ f(x_3)\pnode(0.5ex,0.6ex){fx3}
    \end{array}$ &
      \pnode(-0.5ex,0.6ex){fx1L}f(x_1)\pnode(0.5ex,0.6ex){fx1R} \\ \pnode(-0.5ex,0.6ex){fx2L}f(x_2)\pnode(0.5ex,0.6ex){fx2R}
    \end{array}$ &
      \pnode(-0.5ex,0.6ex){fx0L}f(x_0)\pnode(0.5ex,0.6ex){fx0R} \\ \pnode(-0.5ex,0.6ex){fx12L}f(x_1)\pnode(0.5ex,0.6ex){fx12R}
    \end{array}$ &

Alterations to line style and arrows are also possible. Compilation via latex -> dvips -> ps2pdf or directly using xelatex is required.


a solution with \rnode:

x   & f & \text{I~diff.} & \text{II~diff.} & \text{III~diff.} \\[3mm]
x_0 & f(x_0)                             \\
    &        & f(x_1) & f(x_0)           \\
x_1 & f(x_2) &        &        & 0.0333  \\
    &        & f(x_2) & f(x_1)           \\
x_3 & f(x_3)                             \\
\ncline{2,2}{3,3} \ncline{6,2}{5,3} \ncline{3,3}{3,4}
\ncline{5,3}{5,4} \ncline{3,4}{4,5}\ncline{5,4}{4,5}

enter image description here


no tikz solution yet? Lucky me (in plain-tex format):

\input tikz
\tikzpicture[every on chain/.style={join={by <<-o,blue!60}}]
  \matrix[matrix of math nodes,column sep=2em,row sep=-2ex] (mx) {
    % "mx" is now the name of our matrix, to which we can refer to later
    x   & f      & \hbox{I diff.} & \hbox{II diff.} & \hbox{III diff.} \\[2ex]
    x_0 & f(x_0) \\
        &        & f(x_1)         & f(x_0) \\
    x_1 & f(x_2) &                &                 & 0.0333 \\
        &        & f(x_2)         & f(x_1) \\
    x_2 & f(x_3) \\
  {[start chain]
    \chainin (mx-4-5);
    {[start branch] \chainin (mx-3-4); \chainin (mx-3-3); \chainin (mx-2-2); }
    {[start branch] \chainin (mx-5-4); \chainin (mx-5-3); \chainin (mx-6-2); }

Looks like:
enter image description here

  • I needed the same code but after modifying it I could not join x_{i} and f(x_{i}) by horizontal red arrows. Is that possible too? – bkarpuz Mar 10 '13 at 13:18
  • 1
    @bkarpuz: Sure is possible; for example between x_0 and f(x_0) would be: \draw[red,->] (mx-2-1) -- (mx-2-2);; that reads: mx is the name of the matrix, 2 is the row number, and the last number is the column number. – morbusg Mar 22 '13 at 12:00

Since a MWE was not provided, the following answer is aimed at getting the desired output. I used PSTricks to do positioning and to get line segments.



\rput[tl](6,0){I diff}
\rput[tl](9,0){II diff}
\rput[tl](12,0){III diff}









enter image description here

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.