I am using subcaption
package to plot subfloats in my report. However, the caption for subfigures are not centered. Here is what I have done:
\documentclass[10pt]{report}
\usepackage{epsfig,cite,amsfonts,amssymb,psfrag,balance}
\usepackage[centertags]{amsmath}
\usepackage{amsthm}
\usepackage{newlfont}
\usepackage[ansinew]{inputenc}
\usepackage[justification=centering]{caption}
\usepackage{graphicx,subcaption}
\usepackage{dsfont}
\usepackage{morefloats}
\begin{subfigure}{0.33\textwidth}
\centering
\psfrag{lambda}[][][1.5]{$\log_{10} (\lambda)$}
\psfrag{N}[][][1.5]{Channel Noise Power, $N$}
\resizebox{8cm}{!}{\epsfbox{P3_N_vary.eps}}
\caption{Achievable}
\label{fig:p3_graph1}
\end{subfigure}
\hspace{2.5cm}
\begin{subfigure}{0.33\textwidth}
\centering
\psfrag{lambda}[][][1.5]{$\log_{10} (\lambda)$}
\psfrag{Ps}[][][1.5]{Encoder transmit power, $\ps$}
\resizebox{8cm}{!}{\epsfbox{P3_ps_vary.eps}}
\caption{Achievable }
\label{fig:p3_graph2}
\end{subfigure}
\caption{}
\end{figure}
Am I missing something here? Can somebody help me out please?
Best Answer
Assuming you're using a "standard" paper size (either letterpaper or A4) and "normal" horizontal margins (ca. 1"), your document's
\textwidth
parameter will be equal to roughly 6" (15cm). You allocate an overall width to eachsubfigure
environments of0.33\textwidth
, which works out to about 2" (5cm). Yet, via the\resizebox
instructions, you specify a display width of 8cm for the included graphics. These parameters are not mutually consistent, and thus LaTeX can't perform the centering as requested.To fix up the problem, you may try applying the following changes: (i) specify widths of each subfigure of
0.45\textwidth
instead0.33\textwidth
, (ii) use\linewidth
instead of8cm
as the first argument of the\resizebox
instructions, and (iii) replace the instruction\hspace{2.5cm}
with\hspace{\fill}
.