3

I cannot figure out why out of 3 subtables, only the last one has the caption centered, while the first two captions are shifted off-center. The code is identical for all three subtables and as well as their structures and captions, pretty much.

Can somebody send me a remedy, but without asking me to use some packages that are not compatible with subfig, if possible. Here is the troubling code (I hope this will serve as an MWE):

\documentclass[11pt,twoside]{book}
\usepackage{caption}
\captionsetup{font=small, labelfont=bf, labelsep=period, width=.77\textwidth, justification=centerlast} 
\usepackage{subfig}
\usepackage{mdwtab}
\usepackage{booktabs}
\usepackage{multirow}

\begin{document}

\begin{table}[htbp]
  \caption{Useful ratios and respective dB's}
  \centering
  %
 \subfloat[Power ratios vs. dB]{%
    \vspace{0.5cm}
    \begin{tabular}{|c|c|c|c|c|}
        \hline
        $P/P_{ref}$  &  1  &  2  &  4  & 10 \\
        \hline
          dB         &  0  &  3  &  6  & 10 \\
        \hline
    \end{tabular} 
    \vspace{0.5cm}
  } \\
 % 
  \subfloat[Voltage ratios vs. dB]{%
    \vspace{.5cm}
 \begin{tabular}{|c|c|c|c|c|}
         \hline
         $V/V_{ref}$  &  1  &  2  &  4  & 10 \\
         \hline
           dB        &  0  &  3  &  6  & 10 \\
         \hline
     \end{tabular}
     \vspace{0.5cm}
  } \\
  %
   \subfloat[dB vs. power- and voltage- ratios]{%
   \vspace{0.5cm}
   \begin{tabular}{|c|c|c|c|c|}
           \hline
             dB         &  0  &  3  &  6  & 10 \\
           \hline
           $P/P_{ref}$  &  1  &  2  &  4  & 10 \\
           \hline
           $V/V_{ref}$  &  1  &  $\sqrt{2}$  &  $\sqrt{4}=2$  & $\sqrt{10}$ \\
           \hline
       \end{tabular}
  }
 \label{tab:db_conversions}
\end{table}

\end{document}

The output of this code is shown in the figure here:

Illustration of shifted subtable captions

2
  • 1
    Welcome to TeX.SX! That code works fine here, when inserted into a minimal document (\documentclass{article}\usepackage{subfig}\begin{document}<your table>\end{document}), can you make a complete, minimal working example showing the problem (see meta.tex.stackexchange.com/questions/228 for some discussion on making MWEs)? Oct 10, 2016 at 13:02
  • BTW, you code ends before the last subfloat. Oct 10, 2016 at 14:38

1 Answer 1

2

Drop the width specification you provide through \captionsetup:

enter image description here

\documentclass{book}

\usepackage{caption,amsmath}
\captionsetup{
  font=small,
  labelfont=bf,
  labelsep=period,
  justification=centerlast}
\usepackage{subfig}

\begin{document}

\begin{table}
  \caption{Useful ratios and respective dB's}
  \centering
  \subfloat[Power ratios vs.\ dB]{%
    \begin{tabular}{ *{5}{c} }
      $P/P_{\text{ref}}$  &  1  &  2  &  4  & 10 \\
      \hline
      dB                  &  0  &  3  &  6  & 10
    \end{tabular} 
  }

  \subfloat[Voltage ratios vs.\ dB]{%
    \begin{tabular}{ *{5}{c} }
      $V/V_{\text{ref}}$  &  1  &  2  &  4  & 10 \\
      \hline
      dB                  &  0  &  3  &  6  & 10
     \end{tabular}
  }

  \subfloat[dB vs.\ power- and voltage-ratios]{%
    \begin{tabular}{ *{5}{c} }
      dB                  &  0  &  3  &  6  & 10 \\
      \hline
      $P/P_{\text{ref}}$  &  1  &  2  &  4  & 10 \\
      \hline
      $V/V_{\text{ref}}$  &  1  &  $\sqrt{2}$  &  $\sqrt{4}=2$  & $\sqrt{10}$
    \end{tabular}
  }
\end{table}

\end{document}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .