How can I adjust the vertical / horizontal alignment of a table and its caption in a minipage?
Althought this does not answer your question directly, I'd suggest the threeparttable
package that already offers this feature:
\documentclass{article}
\usepackage{threeparttable}
\begin{document}
\begin{table}
\centering
\begin{threeparttable}
\caption{A quite long caption.}
\begin{tabular}{|c|c|c|}
\hline
one & two & three\\
four & five & six\\
seven & eight & nine\\
\hline
\end{tabular}
\end{threeparttable}
\end{table}
\end{document}
Your code introduce a space at wrong place, immediately before the tabular. Therefore, when printed out, your tabular is placed indented to the right by the width of a space:
\tab{
should be
\tab{% %% <- remove the space produces by the linebreak
Here is your MWE:
\documentclass{article}
%
\newcommand{\tab}[4]{
\setbox0=\hbox{#1}
\begin{table}[htbp]
\begin{center}
\begin{minipage}{\the\wd0}
\caption[#2]{#3\label{#4}}
\box0
\end{minipage}
\end{center}
\end{table}}
%
\begin{document}
%
\tableofcontents
\listoftables
%
\tab{% %%% <- this % makes the difference
\begin{tabular}{|c|c|c|}
\hline
one & two & three\\
four & five & six\\
seven & eight & nine\\
\hline
\end{tabular}}
{Small Table in Minipage}
{A small table in a minipage with a caption that wraps
but is slightly to the left of the table in vertical
alignment.}
{tab:inminipage}
%
\end{document}