1

Here is my code:

\documentclass{article}
\usepackage{fullpage}
\usepackage{pgf-pie}
\usepackage{tabularx}

\usetikzlibrary{decorations.text}
\usepackage{ifthen}


\begin{document}



\begin{table}[ht]
%\caption{Multi-column and multi-row table}
\begin{center}
\begin{tabular}{|p{1.5cm}|>{\centering}p{2.5cm}|>{\centering}p{1.5cm}|>{\raggedleft}p{3cm}|} %{|c|c|c|c|}
    \hline
    Protocol1 & protocol2 & protocol3 \tabularnewline
    \hline
    \multicolumn{1}{|c|}{Speed varies between 5 and 35} 
    \multicolumn{1}{|c|}{\begin{tikzpicture}[font=\scriptsize]
    \begin{scope}[scale=.4,xshift=.5cm]
    \pie[explode=0.2]{8.3/B1, 33.3/B2, 58.3/B3}
    \end{scope}  
    \end{tikzpicture}}  
    \multicolumn{1}{|c|}{\begin{tikzpicture}[font=\scriptsize]
    \begin{scope}[scale=.4,xshift=.5cm]
    \pie[explode=0.2]{33.3/B1, 33.3/B2,33.3/B3}
    \end{scope}  
    \end{tikzpicture}} 
    %\multirow{1}{*}{Multi-col-row}}&X\\
    \multicolumn{1}{|c|}{\begin{tikzpicture}[font=\scriptsize]
    \begin{scope}[scale=.4,xshift=.5cm]
    \pie[explode=0.2]{20.2/B1, 35.5/B2, 44.2/B3}
    \end{scope}  
    \end{tikzpicture}} \\
    \hline
    \multicolumn{1}{|c|}{Speed varies between 5 and 45} 
    \multicolumn{1}{|c|}{\begin{tikzpicture}[font=\scriptsize]
    \begin{scope}[scale=.4,xshift=.5cm]
    \pie[explode=0.2]{6.6/B1, 33.3/B2, 60/B3}
    \end{scope}  
    \end{tikzpicture}}  
    \multicolumn{1}{|c|}{\begin{tikzpicture}[font=\scriptsize]
    \begin{scope}[scale=.4,xshift=.5cm]
    \pie[explode=0.2]{33.3/B1, 33.3/B2,33.3/B3}
    \end{scope}  
    \end{tikzpicture}} 
    %\multirow{1}{*}{Multi-col-row}}&X\\
    \multicolumn{1}{|c|}{\begin{tikzpicture}[font=\scriptsize]
    \begin{scope}[scale=.4,xshift=.5cm]
    \pie[explode=0.2]{19.8/B1, 35.6/B2, 44.4/B3}
    \end{scope}  
    \end{tikzpicture}} \\
    \hline
    \multicolumn{1}{|c|}{Speed varies between 5 and 65} 
    \multicolumn{1}{|c|}{\begin{tikzpicture}[font=\scriptsize]
    \begin{scope}[scale=.4,xshift=.5cm]
    \pie[explode=0.2]{4.7/B1, 33.3/B2, 61.9/B3}
    \end{scope}  
    \end{tikzpicture}}  
    \multicolumn{1}{|c|}{\begin{tikzpicture}[font=\scriptsize]
    \begin{scope}[scale=.4,xshift=.5cm]
    \pie[explode=0.2]{33.3/B1, 33.3/B2,33.3/B3}
    \end{scope}  
    \end{tikzpicture}} 
    %\multirow{1}{*}{Multi-col-row}}&X\\
    \multicolumn{1}{|c|}{\begin{tikzpicture}[font=\scriptsize]
    \begin{scope}[scale=.4,xshift=.5cm]
    \pie[explode=0.2]{19.3/B1, 35.8/B2, 44.7/B3}
    \end{scope}  
    \end{tikzpicture}} \\
    \hline
    \multicolumn{1}{|c|}{Speed varies between 5 and 85} 
    \multicolumn{1}{|c|}{\begin{tikzpicture}[font=\scriptsize]
    \begin{scope}[scale=.4,xshift=.5cm]
    \pie[explode=0.2]{3.7/B1, 33.3/B2, 62.9/B3}
    \end{scope}  
    \end{tikzpicture}}  
    \multicolumn{1}{|c|}{\begin{tikzpicture}[font=\scriptsize]
    \begin{scope}[scale=.4,xshift=.5cm]
    \pie[explode=0.2]{33.3/B1, 33.3/B2,33.3/B3}
    \end{scope}  
    \end{tikzpicture}} 
    %\multirow{1}{*}{Multi-col-row}}&X\\
    \multicolumn{1}{|c|}{\begin{tikzpicture}[font=\scriptsize]
    \begin{scope}[scale=.4,xshift=.5cm]
    \pie[explode=0.2]{19/B1, 36.9/B2, 44.9/B3}
    \end{scope}  
    \end{tikzpicture}} \\
    \hline

\end{tabular}
\end{center}
\label{tab:multicol}
\end{table}



\end{document}

Sample figure

I want to remove the column 5 and remove title protocol in first column and add p-1, p-2 and p-3 as per figure

2 Answers2

2

You need & to seperate cells in the same row.

\documentclass[margin=1]{standalone}
\usepackage{fullpage}
\usepackage{pgf-pie}
\usepackage{tabularx}
\usepackage{tikz}
\usetikzlibrary{decorations.text}
\usepackage{ifthen}
\begin{document}
\begin{tabular}{|c|c|c|c|}
    \hline
    & Protocol1 & protocol2 & protocol3 \tabularnewline
    \hline
    {Speed varies between 5 and 35} &
    \begin{tikzpicture}[font=\scriptsize]
    \begin{scope}[scale=.4,xshift=.5cm]
    \pie[explode=0.2]{8.3/B1, 33.3/B2, 58.3/B3}
    \end{scope}  
    \end{tikzpicture}  &
    \begin{tikzpicture}[font=\scriptsize]
    \begin{scope}[scale=.4,xshift=.5cm]
    \pie[explode=0.2]{33.3/B1, 33.3/B2,33.3/B3}
    \end{scope}  
    \end{tikzpicture} &
    %\multirow{1}{*}{Multi-col-row}}&X\\
    \begin{tikzpicture}[font=\scriptsize]
    \begin{scope}[scale=.4,xshift=.5cm]
    \pie[explode=0.2]{20.2/B1, 35.5/B2, 44.2/B3}
    \end{scope}  
    \end{tikzpicture} \\
    \hline
    {Speed varies between 5 and 45} &
    \begin{tikzpicture}[font=\scriptsize]
    \begin{scope}[scale=.4,xshift=.5cm]
    \pie[explode=0.2]{6.6/B1, 33.3/B2, 60/B3}
    \end{scope}  
    \end{tikzpicture}  &
    \begin{tikzpicture}[font=\scriptsize]
    \begin{scope}[scale=.4,xshift=.5cm]
    \pie[explode=0.2]{33.3/B1, 33.3/B2,33.3/B3}
    \end{scope}  
    \end{tikzpicture} &
    %\multirow{1}{*}{Multi-col-row}}&X\\
    \begin{tikzpicture}[font=\scriptsize]
    \begin{scope}[scale=.4,xshift=.5cm]
    \pie[explode=0.2]{19.8/B1, 35.6/B2, 44.4/B3}
    \end{scope}  
    \end{tikzpicture} \\
    \hline
    {Speed varies between 5 and 65} &
    \begin{tikzpicture}[font=\scriptsize]
    \begin{scope}[scale=.4,xshift=.5cm]
    \pie[explode=0.2]{4.7/B1, 33.3/B2, 61.9/B3}
    \end{scope}  
    \end{tikzpicture}  &
    \begin{tikzpicture}[font=\scriptsize]
    \begin{scope}[scale=.4,xshift=.5cm]
    \pie[explode=0.2]{33.3/B1, 33.3/B2,33.3/B3}
    \end{scope}  
    \end{tikzpicture} &
    %\multirow{1}{*}{Multi-col-row}}&X\\
    \begin{tikzpicture}[font=\scriptsize]
    \begin{scope}[scale=.4,xshift=.5cm]
    \pie[explode=0.2]{19.3/B1, 35.8/B2, 44.7/B3}
    \end{scope}  
    \end{tikzpicture} \\
    \hline
    {Speed varies between 5 and 85} &
    \begin{tikzpicture}[font=\scriptsize]
    \begin{scope}[scale=.4,xshift=.5cm]
    \pie[explode=0.2]{3.7/B1, 33.3/B2, 62.9/B3}
    \end{scope}  
    \end{tikzpicture}  &
    \begin{tikzpicture}[font=\scriptsize]
    \begin{scope}[scale=.4,xshift=.5cm]
    \pie[explode=0.2]{33.3/B1, 33.3/B2,33.3/B3}
    \end{scope}  
    \end{tikzpicture} &
    %\multirow{1}{*}{Multi-col-row}}&X\\
    \begin{tikzpicture}[font=\scriptsize]
    \begin{scope}[scale=.4,xshift=.5cm]
    \pie[explode=0.2]{19/B1, 36.9/B2, 44.9/B3}
    \end{scope}  
    \end{tikzpicture} \\
    \hline
\end{tabular}
\end{document}

enter image description here

2

To put the text in the middle, use m{...} column type.

Please note that, in your case, the scope environments are useless.

I've added \useasboundingbox (-5,-5) rectangle (5,5); so that all the pies have the same bounding box and their center is correctly aligned.

Look also at When should we use \begin{center} instead of \centering?

enter image description here

CarLaTeX
  • 62,716