The following minimal working example does not vertically align two rectangles drawn by TikZ. The result can be found here. Somehow the second rectangle seems bolded, but that is not the case when I open the .pdf on my PC.
I would like the two rectangles to be vertically aligned and centered (which is equivalent to both centering them). Why is the second rectangle indented?
\documentclass[a4paper]{article}
\usepackage{subfig}
\usepackage{tikz,pgfplots}\pgfplotsset{compat = 1.11}
\newcommand{\rect}{%
\begin{tikzpicture}%
\draw (0,0) rectangle (4,4);%
\end{tikzpicture}%
}%
\begin{document}%
\begin{figure}%
\centering%
\subfloat[First rectangle.]{\rect}%
\newline%
\subfloat[Second rectangle.]{\rect}%
\caption{This is a figure with two rectangles that do not horizontally align.}
\end{figure}%
\end{document}


\subfloat[First rectangle.]{\rect}% \newline%by\subfloat[First rectangle.]{\rect}\\%, then it works. Can someone explain why? – Ritz Jan 28 '15 at 13:33\newlinebut\par. – Jan 28 '15 at 14:15\newline, you should use\paror\\;\centeringredefines\\so it behaves well; however,\newlinekeeps its definition as\@normalcr\relax(which is essentially the "normal" definition of\\) and this produces bad results. – Gonzalo Medina Jan 28 '15 at 14:33