1

I try to use \resizebox to fit table in slide, but I reach some error. Please help me fix this problem.

\documentclass{beamer}
\usepackage{graphicx}
\usepackage[labelsep=quad,indention=10pt]{subfig}
\usepackage{tikz}
\usetikzlibrary{matrix,chains,positioning,decorations.pathreplacing,arrows,calc,}
\usetikzlibrary{decorations.markings}
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage{array}% http://ctan.org/pkg/array
\usepackage{amsmath,amsthm,relsize}
\usepackage{adjustbox}
\def \symstalinear{ 
$f(x) = 
\begin{cases}
    -1,                 & \quad \hfill x<-1.\\
    \phantom{-}x,       & \quad \hfill -1 \leq x \leq1\\
    \phantom{-}1,       & \quad \hfill x>1
\end{cases}$
}
\def \hardlimit{
$f(x) = \begin{cases}
  0 &\quad \hfill x<0\\
  1 &\quad \hfill x \geq 0\\
\end{cases}
$
}
\begin{document}
\frame{
 \resizebox{width=\textwidth}{height=\textheight}{
\begin{table}[h!]
    \begin{center}
        \begin{tabular}{ l >{$}c<{$} >{$}c<{$}}
        \toprule
        \textbf{Function} & \multicolumn{1}{c}{\textbf{Definition}}  & \multicolumn{1}{c}{\textbf{Range}} \\
        \midrule
        Linear & f(x)=x & (-\infty,\infty) \\[2ex]
        Log-sigmoid & \dfrac{1}{1+e^{-x}}&(0,1)\\[3ex]
        Hyperbolic Tangent Sigmoid & \dfrac{e^x-e^{-x}}{e^x+e^{-x}}&(-1,1)\\[3ex]
        Symmetric Saturating Linear & $\symstalinear$ & [-1,1] \\[3ex]
        Hard limit & $\hardlimit$ &[0,1]\\
        \bottomrule
        \end{tabular}

    \end{center}
\caption{Definitons of activation function}
\label{tbl:def of act func}
\end{table}%
}
}
\end{document}
2
  • don't resize the table environment, resize the `tabular within it. – David Carlisle Dec 5 '13 at 1:44
  • It still the same error with only tabular. This error is: ! No room for a new \dimen . – phuong Dec 5 '13 at 1:49
6

The command is error for your \resizebox. Should be

\resizebox{xxcm}{!} {  % ! keep the aspectratio with xx width, no need to use width=xx. 
  \begin{tabular}...
  \end{tabular}
}

Also \scalebox from graphicx works too.

\scalebox{0.7}{
  \begin{tabular}...
  \end{tabular}
}

enter image description here

Code

\documentclass{beamer}
\usepackage{graphicx}
\usepackage[labelsep=quad,indention=10pt]{subfig}
%\usepackage{tikz}
%\usetikzlibrary{matrix,chains,positioning,decorations.pathreplacing,arrows,calc,}
%\usetikzlibrary{decorations.markings}
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage{array}% http://ctan.org/pkg/array
\usepackage{amsmath,amsthm,relsize}
%\usepackage{adjustbox} % This seems to cause a problem too.
\def\symstalinear{% 
$f(x) = 
\begin{cases}
    -1,                 & \quad \hfill x<-1.\\
    \phantom{-}x,       & \quad \hfill -1 \leq x \leq1\\
    \phantom{-}1,       & \quad \hfill x>1
\end{cases}$
}
\def\hardlimit{%
$f(x) = \begin{cases}
  0 &\quad \hfill x<0\\
  1 &\quad \hfill x \geq 0
\end{cases}
$
}
\begin{document}
\frame{
\begin{table}[h!]
    \begin{center}
\resizebox{\textwidth}{!}{
        \begin{tabular}{ l >{$}c<{$} >{$}c<{$}}
        \toprule
        \textbf{Function} & \multicolumn{1}{c}{\textbf{Definition}}  & \multicolumn{1}{c}{\textbf{Range}} \\
        \midrule
        Linear & f(x)=x & (-\infty,\infty) \\[2ex]
        Log-sigmoid & \dfrac{1}{1+e^{-x}}&(0,1)\\[3ex]
        Hyperbolic Tangent Sigmoid & \dfrac{e^x-e^{-x}}{e^x+e^{-x}}&(-1,1)\\[3ex]
        Symmetric Saturating Linear & $\symstalinear$ & [-1,1] \\[3ex]
        Hard limit & $\hardlimit$ &[0,1]\\
        \bottomrule
        \end{tabular}
}
    \end{center}
\caption{Definitons of activation function}
\label{tbl:def of act func}
\end{table}%
}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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