19
\documentclass[fleqn,12pt,a4paper]{article}
\usepackage{tabularx}
   \begin{document}
\begin{table}[ht]
  \begin{minipage}[b]{1 \linewidth}\centering
   \begin{tabular}{|c|c|c|c|c|}
    \hline
      Tri Sankhya & Vihbakti    & Ekavachana & Dvivachana & Bahuvachana \\
   \hline
      Pra Trik  & Prathama   & Su (s)& Au & Jas (as) \\
      Dvi Trik & Dvitiya & Am & Aut (Au) & Shas(as) \\
      Tri Trik  & Trutiya  & Ta (A) & Bhyam & Bhis \\ 
      Cha Trik  & Chaturthi  & Ne (E) & Bhyam & Bhyas \\
      Pan   Trik & Panchami  & Nasi (as)& Bhyam & Bhyas  \\
      Shas Trik & Shashthi  & Nas (as)& Os & Aam   \\
      Sap Trik & Saptami & Ni (ee) & Os & Sup(su)  \\
   \hline
     \end{tabular}
      \caption{Subanta Pratyaya}
   \end{minipage}
  \end{table}
 \end{document} 

I am created a table as shown above. However I am trying to create a table as attached in the image. How can I achieve that. The attached image text is in Devanagari but in the above example I changed in to English. I tried unsuccessfully creating nodes in Tikz, also I could find how to achieve free hand outlining over selected table cells. I have no idea how to place the text outside the table and have a arrow connect the text to desired part of table cell. Thanks a million for your help. alt text

David Carlisle
  • 757,742
Aku
  • 11,026

2 Answers2

22

Here's one possibility that can certainly do with a bit more tweaking, but it shows the concept:

\documentclass[fleqn,12pt,a4paper]{article}

\usepackage{tikz}
\usepackage{tabularx}

\begin{document}

% Introduce a new counter for counting the nodes needed for circling
\newcounter{nodecount}
% Command for making a new node and naming it according to the nodecount counter
\newcommand\tabnode[1]{\addtocounter{nodecount}{1} \tikz \node (\arabic{nodecount}) {#1};}

% Some options common to all the nodes and paths
\tikzstyle{every picture}+=[remember picture,baseline]
\tikzstyle{every node}+=[inner sep=0pt,anchor=base,
minimum width=1.8cm,align=center,text depth=.25ex,outer sep=1.5pt]
\tikzstyle{every path}+=[thick, rounded corners]

\begin{table}[ht]
  \begin{minipage}[b]{1 \linewidth}\centering
   \begin{tabular}{|c|c|c|c|c|}
    \hline
      Tri Sankhya & Vihbakti    & Ekavachana & Dvivachana & Bahuvachana \\
   \hline
% Turn the cells needed for defining the circling paths into nodes with our custom command
      Pra Trik  &Prathama  & \tabnode{Su (s)} & \tabnode{Au} & \tabnode{Jas (as)} \\
      Dvi Trik & Dvitiya & \tabnode{Am} & \tabnode{Aut (Au)} & \tabnode{Shas(as)} \\
      Tri Trik  & Trutiya  & \tabnode{Ta (A)} & \tabnode{Bhyam} & Bhis \\ 
      Cha Trik  & Chaturthi  & Ne (E) & Bhyam & Bhyas \\
      Pan   Trik & Panchami  & Nasi (as)& Bhyam & Bhyas  \\
      Shas Trik & Shashthi  & Nas (as)& Os & Aam   \\
      Sap Trik & Saptami & \tabnode{Ni (ee)} & Os & \tabnode{Sup(su)}  \\
   \hline
     \end{tabular}
      \caption{Subanta Pratyaya}
   \end{minipage}


\begin{tikzpicture}[overlay]
% Define the circle paths
\draw [blue](1.north west) -- (3.north east) --
(3.south east) -- (3.south west) -- (5.south east) -- (4.south west) -- cycle;
\draw [red] (6.north west) -- (6.north east) --
(10.south east) -- (9.south west) -- (7.north west) -- (8.north east) -- cycle;
\draw [orange] (2.north west) -- (2.north east) -- (5.south east) --
(5.south west) -- cycle;

% Labels
\node [right=2cm,above=2cm,minimum width=0pt] at (2) (A) {A};
\draw [<-,out=5,in=180] (2) to (A);
\node [right=2.2cm,above=1cm,minimum width=0pt] at (3) (B) {B};
\draw [<-,out=0,in=180] (3) to (B);
\node [right=1.2cm,below=1cm,minimum width=0pt] at (10) (C) {C};
\draw [<-,out=350,in=90] (10) to (C);

\end{tikzpicture}

\end{table}
\end{document} 

A table with groups of cells circled and labelled with callouts

David Carlisle
  • 757,742
Jake
  • 232,450
  • Thanks for your help it worked great. When I ran for the first time it did not as all A B C came to the bottom left, however running the second time produced the image above. – Aku Jan 21 '11 at 22:58
  • 4
    @Aku: That behaviour of TikZ is to be expected; you'll need two compilations most of the time. – Hendrik Vogt Jan 22 '11 at 08:43
0

A solution with {NiceTabular} of nicematrix which creates a tabular with TikZ nodes under the cells and TikZ to draw the lines.

The TikZ instructions are those of Jake's answer.

\documentclass[fleqn,12pt,a4paper]{article}
\usepackage{nicematrix,tikz}

\begin{document}

\tikzset { every path/.append style = { thick, rounded corners } , every node/.append style = { inner sep=0pt, anchor=base, minimum width=1.8cm, align=center, text depth=.25ex, outer sep=1.5pt } }

\begin{table}[ht] \centering \begin{NiceTabular}{ccccc}[vlines,create-medium-nodes] \hline Tri Sankhya & Vihbakti & Ekavachana & Dvivachana & Bahuvachana \ \hline Pra Trik &Prathama & Su (s) & Au & Jas (as) \ Dvi Trik & Dvitiya & Am & Aut (Au) & Shas(as) \ Tri Trik & Trutiya & Ta (A) & Bhyam & Bhis \ Cha Trik & Chaturthi & Ne (E) & Bhyam & Bhyas \ Pan Trik & Panchami & Nasi (as)& Bhyam & Bhyas \ Shas Trik & Shashthi & Nas (as)& Os & Aam \ Sap Trik & Saptami & Ni (ee) & Os & Sup(su) \ \hline \CodeAfter \begin{tikzpicture} [name suffix = -medium] % Define the circle paths \draw [blue] (2-3.north west) -- (2-5.north east) -- (2-5.south east) -- (2-5.south west) -- (3-4.south east) -- (3-3.south west) -- cycle ; \draw [red] (3-5.north west) -- (3-5.north east) -- (8-5.south east) -- (8-3.south west) -- (4-3.north west) -- (4-4.north east) -- cycle ; \draw [orange] (2-4.north west) -- (2-4.north east) -- (3-4.south east) -- (3-4.south west) -- cycle;

% Labels
\node [right=2cm,above=2cm,minimum width=0pt] at (2-4) (A) {A};
\draw [&lt;-,out=5,in=180] (2-4) to (A);
\node [right=2.2cm,above=1cm,minimum width=0pt] at (2-5) (B) {B};
\draw [&lt;-,out=0,in=180] (2-5) to (B);
\node [right=1.2cm,below=1cm,minimum width=0pt] at (8-5) (C) {C};
\draw [&lt;-,out=350,in=90] (8-5) to (C);
\end{tikzpicture}

\end{NiceTabular} \caption{Subanta Pratyaya} \end{table} \end{document}

Output of the above code

F. Pantigny
  • 40,250