1

I can't center the table with the following code, but the caption is in the center:

\begin{table}[h]
  \centering
  \resizebox{0.8\textwidth}{!}{\begin{minipage}{\textwidth}
       \caption{\textbf{State Table for Example 1}}
  \label{table: state table1}
\begin{tabular}{cc|cc}

x & y & X & Y \\ 
\hline
   $\bar{0}$  & $\bar{0}$ & 1 &1 \\ 
   0  & 1 & 0 &1 \\ 
   $\bar{1}$  & $\bar{1}$ & 0 & 0 \\ 
   1  & 0 & 1 &0 \\ 

  \end{tabular}
      \end{minipage}}
\end{table}

Any suggestion?

0

Now it works:

\documentclass{article}

\usepackage{graphicx}
\begin{document}

\begin{table}[h]
  \centering

\resizebox{0.8\textwidth}{!}{\begin{minipage}{\textwidth}
       \caption{\textbf{State Table for Example 1}}
  \label{table: state table1}

\hfil % This is new 
\begin{tabular}{cc|cc}
x & y & X & Y \\ 
\hline
   $\bar{0}$  & $\bar{0}$ & 1 &1 \\ 
   0  & 1 & 0 &1 \\ 
   $\bar{1}$  & $\bar{1}$ & 0 & 0 \\ 
   1  & 0 & 1 &0 \\ 
  \end{tabular}
      \end{minipage}}

\end{table}

\end{document}

enter image description here

0

You have centered the outer box that contains the minipage but the contents inside the minipage need another \centering:

\documentclass{article}

\usepackage{graphicx,showframe}  %% showframe just for demo
\begin{document}

\begin{table}[h]
  \centering    %%% centers the following box
\resizebox{0.8\textwidth}{!}{\begin{minipage}{\textwidth}
  \centering              %% <-- this is for centering inside minipage
  \caption{\textbf{State Table for Example 1}}
  \label{table: state table1}
    \begin{tabular}{cc|cc}
      x & y & X & Y \\
       \hline
     $\bar{0}$  & $\bar{0}$ & 1 &1 \\
     0  & 1 & 0 &1 \\
     $\bar{1}$  & $\bar{1}$ & 0 & 0 \\
     1  & 0 & 1 &0 \\
    \end{tabular}
  \end{minipage}
}
\end{table}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.