# \newdimen in LaTeX is 0pt after assignment, why?

In the below example, I print out the two dimens in the subfigure captions. Surprisingly (to me), the first one prints correctly but the second one is somehow zero pts.

Here is the MWE:

\documentclass{beamer}

\usepackage{subcaption}

\begin{document}
\frame{\frametitle{testing}
\begin{figure}
\begin{tabular}{cc}

\newdimen\fluxfigwidth
\fluxfigwidth=0.5\textwidth
\newdimen\fluxlegwidth
\fluxlegwidth=\textwidth
% I want to do this eventually:
% \begin{subfigure}[lb]{\fluxfigwidth\textwidth}
\begin{subfigure}[lb]{\fluxfigwidth}
\caption{\the\fluxfigwidth}
\includegraphics[width=\textwidth]{tiger}
\end{subfigure}
&
\begin{subfigure}[lb]{\fluxlegwidth}
\caption{\the\fluxlegwidth}
\raisebox{0.3\height}{\includegraphics[scale=0.4,center]{tiger}}
\end{subfigure}
\\
\end{tabular}
\end{figure}
} % end of \frame
\end{document}

-
This is not a minimal working example because it does not include a complete (but minimal!) preamble and \begin/\end{document} tags. Also this is a LaTeX question but you have tagged it as "plain TeX". –  Will Robertson Jun 11 '14 at 1:58
Fair points - thanks, fixed. –  bbarker Jun 11 '14 at 2:08
This example still doesn't actually compile. –  Alan Munn Jun 11 '14 at 2:35
never trust myself with latex I guess - forgot subcaption. Please substitute tiger.eps with an eps of your choice. –  bbarker Jun 11 '14 at 2:42
Also, I just moved subcaptions above figures to be visible with tiger.eps. –  bbarker Jun 11 '14 at 2:50

Each cell within a tabular forms a group, so setting a length inside a cell doesn't last beyond that group. Define and set the lengths outside the tabular.

If you're interested in setting two figures next to one another, there's no need to use a subfigure:

\documentclass{beamer}

\begin{document}

\begin{frame}
\frametitle{testing}
\centering
\begin{tabular}{cc}
\includegraphics[width=.4\linewidth]{example-image-a}
&
\includegraphics[width=.4\linewidth]{example-image-b} \\
Caption A & Caption B
\end{tabular}
\end{frame}

\end{document}

-

Each table cell is a group, therefore your assignments can't make it over the &. I'm not sure what you're after, but using \global\fluxfigwidth=0.5\textwidth should do the trick.

-