4

I'm trying to create a latex table, but I need some features such as:

enter image description here

Is there a latex package that can help me?

  • 6
    There are lots of questions available at this site asking the same. You could have a look here for example. – epR8GaYuh Dec 9 '16 at 13:23
5

enter image description here

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{tikzmark,calc}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{ccc}
\toprule
Probability & 1 & 2\\
\midrule
0.4             &             0.4             &             0.4 \\
0.3             &             0.3             &             0.3 \\
0.1             &             0.1             & \tikzmark{f}0.2 \\
0.1             &             0.1\tikzmark{e} &             0.1 \\
0.06\tikzmark{a}& \tikzmark{c}0.1\tikzmark{d} &                 \\
0.04\tikzmark{b}&                             &                 \\
\bottomrule
\end{tabular}
\begin{tikzpicture}[remember picture,overlay]
  \draw[->] ($(pic cs:a)+(0.1,0.1)$) -- ($(pic cs:c)+(-0.1,0.1)$);
  \draw[->] ($(pic cs:b)+(0.1,0.1)$) -- ++(0.3,0) |- ($(pic cs:c)+(-0.1,0)$);
  \draw[->] ($(pic cs:e)+(0,0.1)$) to[out=0,in=180] ($(pic cs:f)+(0,0.1)$);
  \draw[->] ($(pic cs:d)+(0,0.1)$) to[out=0,in=210] ($(pic cs:f)+(0,0)$);
\end{tikzpicture}
\end{document}

You have to run pdflatex twice for the location information to propagate.

| improve this answer | |
4
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[frenchb]{babel}
\usepackage{array}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\begin{tabular}{|cccccc|}
  \hline
  \multicolumn{3}{|c}{Original source} & \multicolumn{3}{c|}{source reduction}\\
  \hline
  Symbol & Probability & 1 & 2 & 3 & 4 \\
  \emph{a2} & 0.4  & 0.4 & 0.4 & 0.4 & \tikz[overlay,
                                       remember picture]
                                       \node[name=06, anchor=base] {0.6}; \\
  \emph{a6} & 0.3  & 0.3 & 0.3 & 0.3 & \\
  \emph{a1} & 0.1  & 0.1 & 0.2 & 0.3 & \\
  \emph{a4} & 0.1  & 0.1 & 0.1 &     & \\
  \emph{a3} & \tikz[overlay, remember picture] \node[name=006, anchor=base] {0.06}; & \tikz[overlay, remember picture] \node[name=01, anchor=base] {0.1};&     &     & \\
  \emph{a5} & \tikz[overlay, remember picture] \node[name=004, anchor=base] {0.04}; &     &     &     & \\
  \hline
\end{tabular}
\tikz[overlay, remember picture] \draw [->] (006) -- (01);
\tikz[overlay, remember picture] \draw [->] (004) -| ($(004)+(8mm,0)$) |- (01);
\end{document}

enter image description here

| improve this answer | |

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