# Center a table and figure on a page on the same line

So I am trying to make a page of a Latex document which has an image next to a table below another image. I was trying to use the subfigure command to center them, but due to the subfigure command automatically trying to call the caption command, this does not work. Is there any workaround, or better way of doing this?

I'm new to Latex, so I know this is probably not an elegant solution to begin with, and am open to suggestions.

The error I am getting back is:

! Package caption Error: \setcaptionsubtype outside float.

\documentclass[twoside]{article} %Two-sided document. Required for fancyhf left and right page numbering scheme current.
\usepackage{graphicx}

\usepackage{fancyhdr} %Use the package fancy header/footer

\usepackage[letterpaper,margin=0.5in,bottom=0.75in,top=0.7in]{geometry} %Ensure the paper is letterpaper.
\usepackage{grffile}
\usepackage{caption}
\usepackage{float} %Float used to position graphics.
\usepackage{lastpage209} %For last page
\usepackage[table,x11names,dvipsnames,table]{xcolor}
\usepackage{booktabs,array,arydshln}
\usepackage{subcaption}

\begin{document}

\begin{center}

\begin{subfigure}{0.5\textwidth}

\includegraphics[trim={0 0 0 0},clip,width=2.5in]{{Q:/Assembly Metrology/Bench Figures/LWIR1/mtf\string_0 Degrees, Roll 0 Graph_Legend.pdf}}

\captionsetup{labelformat=empty}

\end{subfigure}

\definecolor{Oddrows}{rgb}{ 0.84,0.84,0.84 }
\definecolor{Evenrows}{rgb}{ 1,1,1 }

\begin{subfigure}{0.5\textwidth}

\rowcolors{2}{Oddrows}{Evenrows}
\begin{tabular}{ p{0.5in} p{0.5in}}
\toprule

\multicolumn{1}{>{\centering}m{0.5in}}{\textbf{Display Freq.}} &
\multicolumn{1}{>{\centering}m{0.5in}}{\textbf{29.4}} \\

\midrule
\raggedright Peak Tan. &  \centering\arraybackslash 62.4416 \\
\raggedright Peak Sag. &  \centering\arraybackslash 62.6273 \\
\raggedright Peak Avg. &  \centering\arraybackslash 62.5345 \\
\raggedright Best Pos. &  \centering\arraybackslash 1 \\

\bottomrule
\end{tabular}
\end{subfigure}
\end{center}

\end{document}

I've tried to cut out as much code as necessary, but know I am including more packages than I need to as I use them above this snippet of code, but am not familiar enough with Latex to be able to exclude them.

I am using PDFLatex to compile this.

i suspect that you looking for the following result:

• path name should not have spaces (for their use you should use a special package, for it and its use search the site)
• code is full of clutter, so it is easy to lost in it
• purpose of \captionsetup is not clear. in your mwe you not use caption
• i suggest not to use subfugure. instead it standard tabular will do the job better:

\documentclass[twoside]{article} %Two-sided document. Required for fancyhf left and right page numbering scheme current.
\usepackage[letterpaper,
margin=0.5in,
bottom=0.75in,
top=0.7in]{geometry} %Ensure the
%\usepackage{fancyhdr} %Use the package fancy header/footer paper is letterpaper. not used in this mwe
%\usepackage{grffile} % i haven't this package
\usepackage{caption}
%\usepackage{float} %Float used to position graphics. better not to use
\usepackage{lastpage209} %For last page -- it is rather obsolete ...
\usepackage[table,x11names,dvipsnames,table]{xcolor}
\definecolor{Oddrows}{rgb}{ 0.84,0.84,0.84 }
\definecolor{Evenrows}{rgb}{ 1,1,1 }

\usepackage{booktabs,array,arydshln}
\usepackage{caption}
\usepackage{subcaption}

\usepackage{siunitx}        % new, for nicer aligning of numbers in table
\usepackage{etoolbox}       % new, for making command \bfseries robust

\begin{document}
\begin{center}
\robustify\bfseries         % <---
\begin{tabular}{cc}
\includegraphics[trim={0 0 0 0},clip, valign=c, width=2.5in]{example-image-duck}
&
\rowcolors{2}{Oddrows}{Evenrows}
\begin{tabular}{>{\raggedright}p{0.5in} S[table-format=2.4,
detect-weight]}
\toprule
\multicolumn{1}{c}{\textbf{Display Freq.}}
&   \bfseries 29.4      \\
\midrule
Peak Tan.   & 62.4416   \\
Peak Sag.   & 62.6273   \\
Peak Avg.   & 62.5345   \\
Best Pos.   &  1        \\
\bottomrule
\end{tabular}
\end{tabular}
\end{center}
\end{document}

• Thank you Zarko. This is definitely what I was looking for. I had a question about the option in the table S[table-format=2.4]. What does this do? I also have one image and some formatting I left off of this which uses fancy header/footer. – Colorful Ed Dec 10 '18 at 12:59
• @ColorfulEd, S[table-format=2.4] is definition for the second column style (S columns are defined in the siunitx package). it reserved 2 integer and 4 decimal space for numbers, which are aligned at decimal point. if you not liked, you can replace it wit c column specifier and have all numbers centered. now i edit answer and make table more consistent (added are package etoolbox any second column header is now aligned at decimal point). if the answer solve your problem, you can accept it (by clicking on check mark at top left aide of the answer). – Zarko Dec 10 '18 at 13:29
• Got it. Thank you so much Zarko. I appreciate the help! – Colorful Ed Dec 10 '18 at 13:57