I have a tabular which gets aligned to the right while I use \centering
. I'm using the article class with only the packages babel and array. The code I have:
\documentclass[paper=a4]{article} % A4 paper and 11pt font size
\usepackage[dutch]{babel} % Dutch language/hyphenation
\usepackage{array}
\newcolumntype{+}{>{\global\let\currentrowstyle\relax}}
\newcolumntype{^}{>{\currentrowstyle}}
\newcommand{\rowstyle}[1]{\gdef\currentrowstyle{#1}%
#1\ignorespaces
}
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\begin{document}
\begin{table}[h]
\newcommand\colwidth{10pt}
\let\oldmulticolumn\multicolumn
\renewcommand\multicolumn[3]{\oldmulticolumn{#1}{#2}{\textrm{#3}}}
\centering
\texttt{
\begin{tabular}{+r || ^C{\colwidth} | ^C{\colwidth} | ^C{\colwidth} | ^C{\colwidth} || ^C{\colwidth} | ^C{\colwidth} | ^C{\colwidth} | ^C{\colwidth} || ^C{\colwidth} | ^C{\colwidth} | ^C{\colwidth} | ^C{\colwidth} || ^C{\colwidth} | ^C{\colwidth} | ^C{\colwidth} | ^C{\colwidth} ||}
\rowstyle{\normalfont}
& 15 & 14 & 13 & 12 & 11 & 10 & 9 & 8 & 7 & 6 & 5 & 4 & 3 & 2 & 1 & 0 \\\hline
LOADHI & \multicolumn{3}{c|}{dest} & 0 & \multicolumn{4}{c||}{const} & \multicolumn{4}{c||}{const} & \multicolumn{4}{c||}{const} \\\cline{6-9}
LOADLO & \multicolumn{3}{c|}{dest} & 1 & \multicolumn{3}{c|}{addr. B} & 1 & \multicolumn{4}{c||}{const} & \multicolumn{4}{c||}{const} \\\hline
ALUf & \multicolumn{3}{c|}{dest} & 1 & \multicolumn{3}{c|}{addr. B} & 0 & 1 & \multicolumn{3}{c||}{addr. A} & 1 & \multicolumn{3}{c||}{opcode} \\
ALU & \multicolumn{3}{c|}{dest} & 1 & \multicolumn{3}{c|}{addr. B} & 0 & 0 & \multicolumn{3}{c||}{addr. A} & 1 & \multicolumn{3}{c||}{opcode} \\\cline{10-13}
ALU & \multicolumn{3}{c|}{dest} & 1 & \multicolumn{3}{c|}{addr. B} & 0 & \multicolumn{4}{c||}{const. A} & 0 & \multicolumn{3}{c||}{opcode} \\\hline
READ & \multicolumn{3}{c|}{dest} & 1 & \multicolumn{3}{c|}{addr. B} & 0 & 1 & \multicolumn{3}{c||}{addr. A} & 1 & 1 & 1 & 1 \\\cline{10-13}
READ & \multicolumn{3}{c|}{dest} & 1 & \multicolumn{3}{c|}{addr. B} & 0 & \multicolumn{4}{c||}{const. A} & 0 & 1 & 1 & 1 \\\cline{2-5}\cline{10-13}
WRITE & 0 & 0 & 0 & 0 & \multicolumn{3}{c|}{addr. B} & 0 & & \multicolumn{3}{c||}{addr. A} & 1 & & & \\\hline
COND\_CHK & 0 & 0 & 0 & 0 & & & & 1 & & & & & \multicolumn{4}{c||}{condition}\\\hline
\end{tabular}
}
\caption{Instruction set}
\end{table}
\end{document}
The table may be a bit complicated on the inside, but I don't see why it should get aligned to the right, like here. The grey sides are the ends of the document. You can clearly see the caption is centered, but the tabular is not.
Why is that and how can I fix it?