Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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:
% \advance\fluxlegwidth-\fluxfigwidth
% \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}
share|improve this question
    
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 at 1:58
    
Fair points - thanks, fixed. –  bbarker Jun 11 at 2:08
    
This example still doesn't actually compile. –  Alan Munn Jun 11 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 at 2:42
    
Also, I just moved subcaptions above figures to be visible with tiger.eps. –  bbarker Jun 11 at 2:50

2 Answers 2

up vote 3 down vote accepted

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:

enter image description here

\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}
share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.