2

I have tried many combinations for centering following table, but none seems to work... Help much appreciated..

 \RequirePackage[l2tabu, orthodox]{nag}
 \documentclass[12pt]{article}

  \usepackage{amsmath, amsthm, amsfonts, amssymb, mathtools}
  \usepackage[algoruled,lined,linesnumbered,titlenotnumbered]{algorithm2e}
  \usepackage{array}
  \usepackage{booktabs}
  \usepackage{color}
  \usepackage{comment}
  \usepackage{fixltx2e}
  \usepackage[T1]{fontenc}
  \usepackage[a4paper]{geometry}
  \usepackage[pdftex]{graphicx}
  \usepackage{lmodern}
  \usepackage{listings}
  \usepackage{microtype}
  \usepackage{multirow}
  \usepackage{pdfpages}
  \usepackage{pgfplots}
  \usepackage{tikz}
  \usepackage{siunitx}
  \usepackage{float}

  \usepackage{subfigure}

  \begin{document}
  \begin{center}
  \begin{table}[!ht] 

  \begin{tabular}{|c|c|p{8.5cm}|} 
  \hline
  \begin{tikzpicture}
  \begin{axis}[
   legend style={fill=none},
   xlabel={Time}, 
   ylabel={Values}
   ]

   \pgfkeys{
   /pgf/number format/precision=5, 
}

\pgfplotstableread
{
thread  speedup
24   321.179125106 
48   324.194761473  
309  341.576483167 
}\datafile

\addplot table[x=thread,y=speedup,color=red,mark=x] {\datafile};
\addlegendentry{a=10, b=10}

\pgfplotstableread
{
thread  speedup
24   321.166812198 
48   324.1978397  
309  341.561092032 
}\datafile

\addplot table[x=thread,y=speedup,color=red,mark=x] {\datafile};
\addlegendentry{a=10, b=5}

\pgfplotstableread
{
thread  speedup
24   324.968422522 
48   327.766530848   
309  343.636843094 
}\datafile

\addplot table[x=thread,y=speedup,color=red,mark=x] {\datafile};
\addlegendentry{a=10, b=1}

\end{axis}
\end{tikzpicture}  & 

\begin{tikzpicture}
\begin{axis}[
  legend style={fill=none},
  xlabel={Time}, 
  ylabel={Values }
 ]

\pgfkeys{
  /pgf/number format/precision=5, 
}

\pgfplotstableread
{
thread  speedup
24  321.179125106  
48  324.194761473   
309 341.576483167 
}\datafile

\addplot table[x=thread,y=speedup,color=red,mark=x] {\datafile};
\addlegendentry{a=10, b=10}

\pgfplotstableread
{
thread  speedup
24   321.163733971  
48   324.186552868 
309  341.564170259 
}\datafile

\addplot table[x=thread,y=speedup,color=red,mark=x] {\datafile};
\addlegendentry{a=10, b=5}

\pgfplotstableread
{
thread  speedup
24  322.213409372 
48  325.215706756 
309 342.349118139 
}\datafile

\addplot table[x=thread,y=speedup,color=red,mark=x] {\datafile};
\addlegendentry{a=10, b=1}


\end{axis}
\end{tikzpicture}   \\

Parameter1 & Parameter2\\
\hline
\end{tabular}



\caption{Caption}
\label{table:time}
\end{table}
\end{center}

\end{document}
  • 1
    also do not put center around the outside of table (it just adds spurious space without centering anything) use \centering inside \begin{table} – David Carlisle Dec 11 '14 at 16:38
  • 1
    The subfigure package is deprecated; use either subfig or subcaption. – Mico Dec 11 '14 at 17:03
  • off topics: mathtools kind of loads amsmath so just load the prior. Load xcolor instead of color, use subcaption instead of subfigure, pgfplots loads tikz so that's redundant. Do not use \begin{center} unless you know, what you are doing. If you load booktabs you should also use that nice package... (maybe not here). Last thing: You might want to use the legend style legend style={at={(0.02,0.98)},anchor=north west},legend cell align=left, – LaRiFaRi Dec 12 '14 at 06:51

1 Answers1

2

enter image description here

Centering needs to be applied within the float, not around it. There was a spurious third column in the tabular and I scaled the two tikzpicture a bit so they fitted.

\RequirePackage[l2tabu, orthodox]{nag}
 \documentclass[12pt]{article}

  \usepackage{amsmath, amsthm, amsfonts, amssymb, mathtools}
  \usepackage[algoruled,lined,linesnumbered,titlenotnumbered]{algorithm2e}
  \usepackage{array}
  \usepackage{booktabs}
  \usepackage{color}
  \usepackage{comment}
  \usepackage{fixltx2e}
  \usepackage[T1]{fontenc}
  \usepackage[a4paper]{geometry}
  \usepackage[pdftex]{graphicx}
  \usepackage{lmodern}
  \usepackage{listings}
  \usepackage{microtype}
  \usepackage{multirow}
  \usepackage{pdfpages}
  \usepackage{pgfplots}
  \usepackage{tikz}
  \usepackage{siunitx}
  \usepackage{float}

  \usepackage{subfigure}

  \begin{document}

  \begin{table}[!ht] \centering

  \begin{tabular}{|c|c|} 
  \hline
  \begin{tikzpicture}[scale=0.7]
  \begin{axis}[
   legend style={fill=none},
   xlabel={Time}, 
   ylabel={Values}
   ]

   \pgfkeys{
   /pgf/number format/precision=5, 
}

\pgfplotstableread
{
thread  speedup
24   321.179125106 
48   324.194761473  
309  341.576483167 
}\datafile

\addplot table[x=thread,y=speedup,color=red,mark=x] {\datafile};
\addlegendentry{a=10, b=10}

\pgfplotstableread
{
thread  speedup
24   321.166812198 
48   324.1978397  
309  341.561092032 
}\datafile

\addplot table[x=thread,y=speedup,color=red,mark=x] {\datafile};
\addlegendentry{a=10, b=5}

\pgfplotstableread
{
thread  speedup
24   324.968422522 
48   327.766530848   
309  343.636843094 
}\datafile

\addplot table[x=thread,y=speedup,color=red,mark=x] {\datafile};
\addlegendentry{a=10, b=1}

\end{axis}
\end{tikzpicture}  & 

\begin{tikzpicture}[scale=0.7]
\begin{axis}[
  legend style={fill=none},
  xlabel={Time}, 
  ylabel={Values }
 ]

\pgfkeys{
  /pgf/number format/precision=5, 
}

\pgfplotstableread
{
thread  speedup
24  321.179125106  
48  324.194761473   
309 341.576483167 
}\datafile

\addplot table[x=thread,y=speedup,color=red,mark=x] {\datafile};
\addlegendentry{a=10, b=10}

\pgfplotstableread
{
thread  speedup
24   321.163733971  
48   324.186552868 
309  341.564170259 
}\datafile

\addplot table[x=thread,y=speedup,color=red,mark=x] {\datafile};
\addlegendentry{a=10, b=5}

\pgfplotstableread
{
thread  speedup
24  322.213409372 
48  325.215706756 
309 342.349118139 
}\datafile

\addplot table[x=thread,y=speedup,color=red,mark=x] {\datafile};
\addlegendentry{a=10, b=1}


\end{axis}
\end{tikzpicture}   \\

Parameter1 & Parameter2\\
\hline
\end{tabular}



\caption{Caption}
\label{table:time}
\end{table}


\end{document}
David Carlisle
  • 757,742