For small figures, I want for captions to go on the right or on the left depending on the page number, whether it is odd or even. To do that I define the command \row as follows:
\newcommand{\row}[2]{%
\ifodd\value{page}
#2 \hfil #1
\else
#1 \hfil #2
\fi
}
Typically, it is used inside the figure environment, for example,
\begin{figure}
\row{%
\begin{minipage}[c]{0.67\textwidth}
\includegraphics[width=\textwidth]{2011-03-03}
\end{minipage}%
}{%
\begin{minipage}[c]{0.3\textwidth}
\caption{The transition temperature vs. density of the hydrogen}
\label{fig:03-03}
\end{minipage}}
\end{figure}
This works as desired in most cases, however, sometimes, placement of the caption goes wrong. I wonder why? And how to modify my code to avoid troubles?